1
\$\begingroup\$

I am using MSP430F5529 and MSP430 Driver Library.

As you can see, I set upMode timer configuration, compare mode configuration and enabled the initial interrupts. However, timerA interrupt is not working, I set an indicator whether cod jumps into interrupt or not: ucsFault should be different than 0 if interrupt is working but obviously not. And I don't know where am I doing wrong. I appreciate any help. Thanks in advance.

#include "driverlib.h"

uint32_t fq_SMCLK = 0;

uint32_t ucsFault;

void setConf(void);
void clockConfiguration(void);

int main(void) {

    WDT_A_hold(WDT_A_BASE);
    P1DIR |= BIT0;
    P1OUT &= ~BIT0;
    clockConfiguration();
    setConf();
    fq_SMCLK = UCS_getSMCLK();

    while(1);

}

void setConf(void)
{

    Timer_A_initUpModeParam upMode =
    {

        //uint16_t clockSource;
        TIMER_A_CLOCKSOURCE_SMCLK,
        //uint16_t clockSourceDivider;
        TIMER_A_CLOCKSOURCE_DIVIDER_64,
        //uint16_t timerPeriod;
        ((4000000/16/64)/120),
        //uint16_t timerInterruptEnable_TAIE;
        TIMER_A_TAIE_INTERRUPT_ENABLE,
        //uint16_t captureCompareInterruptEnable_CCR0_CCIE;
        TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE,
        //uint16_t timerClear;
        //TIMER_A_DO_CLEAR,
        TIMER_A_SKIP_CLEAR,
        //bool startTimer;
        1
    };

    Timer_A_initCompareModeParam comp =
    {
        //uint16_t compareRegister;
        TIMER_A_CAPTURECOMPARE_REGISTER_1,
        //uint16_t compareInterruptEnable;
        TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE,
        //uint16_t compareOutputMode;
        TIMER_A_OUTPUTMODE_TOGGLE_RESET,
        //uint16_t compareValue;
        ((4000000/16/64)/120)*4/5
    };

    Timer_A_initUpMode(0x0340, &upMode);

    Timer_A_initCompareMode(0x0340, &comp);

    Timer_A_enableCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_1);

    Timer_A_enableInterrupt(0x0340);

    Timer_A_startCounter(0x0340, TIMER_A_UP_MODE);



}



void clockConfiguration(void)
{


    P5SEL |= BIT2+BIT3;                       // Port select XT2

    UCS_initClockSignal(UCS_SMCLK, UCS_XT2CLK_SELECT, UCS_CLOCK_DIVIDER_16);

    UCS_turnOnXT2(UCS_XT2_DRIVE_4MHZ_8MHZ);

    UCS_turnOnSMCLK();

    UCS_setExternalClockSource(32000, 4000000);

    UCS_enableClockRequest(UCS_SMCLK);

}

#pragma vector = TIMER0_A0_VECTOR
__interrupt void __isr_Timer_A(void)
{
    ucsFault = 1;
    switch(TA0IV)
    {
    case 0:
        Timer_A_clearTimerInterrupt(0x0340);
        Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_0);
        Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_1);
        P1OUT |= BIT0;
        ucsFault = 2;
        break;
    case 2:
        Timer_A_clearTimerInterrupt(0x0340);
        Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_0);
        Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_1);
        P1OUT &= ~BIT0;
        ucsFault = 3;
        break;
    }
}
\$\endgroup\$
  • \$\begingroup\$ What is the meaning of those magic numbers 0x0340, 0, and 2? Why aren't you using symbols? \$\endgroup\$ – CL. Feb 3 '16 at 19:35
  • \$\begingroup\$ 0x0340 is Base Address of TimerA module. Driver Library works that way. This is the dataheet: ti.com/lit/ds/symlink/msp430f5529.pdf \$\endgroup\$ – Alper91 Feb 3 '16 at 19:43
  • \$\begingroup\$ TA0IV interrupt vector, for CCR0 flag: 1, CCR1 flag: 2 , CCR2 flag: 4 and goes like that \$\endgroup\$ – Alper91 Feb 3 '16 at 19:47
  • \$\begingroup\$ Why aren't you using the symbols defined for that? \$\endgroup\$ – CL. Feb 3 '16 at 19:47
  • \$\begingroup\$ You are right I should have defined for simplicity and I will in a minute. Just, I am not much of an Embedded guy, so not much experience with coding. Sorry. \$\endgroup\$ – Alper91 Feb 3 '16 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.