This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430FR2633: pragma vector timer routine issue

Part Number: MSP430FR2633
Other Parts Discussed in Thread: MSPWARE, CAPTIVATE-FR2633, TEST2, CC1310

Tool/software: Code Composer Studio

Working on a Captivate project and want to start a timer-oscillator from a touch event to drive a piezo sounder.  Tested a timer program example on my MSP430FR2633 Captivate board and all went well.  Then inserted the same code into the modified Captivate main.c page(where I drive LED's from events) and get a "pragma vector..." error.  The code that works on the board outside of the Captivate program is as follows:


int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT

// Configure GPIO
P1DIR |= BIT0; // P1.0 output
P1OUT |= BIT0; // P1.0 high

// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;

TA0CCTL0 |= CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 5000; //changed from 50000
TA0CTL |= TASSEL__SMCLK | MC__CONTINUOUS; // SMCLK, continuous mode

__bis_SR_register(LPM0_bits | GIE); // Enter LPM3 w/ interrupts
__no_operation(); // For debug
}

// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
P1OUT ^= BIT0;
TA0CCR0 += 600; // Add Offset to TACCR0, changed from 50000
}

What am I missing?  Main error seems to state "pragma vector can only be applied to a function definition, not Timer_A".  Again, it all works well outside of Captivate.  Should I be using a different timer?  Somewhat new to embedded programming.

  • It would be more useful to see the code that fails.

    My guess is a typo: Maybe a missing closing brace, a stray semicolon, or a misspelling of e.g. __interrupt. Somehow, you're preventing the compiler from seeing the line starting "__interrupt" as a function definition.
  • Michael,

    Would you be able to provide the source code for both projects so I can debug why you are getting that error?

    Best regards,

    Matt
  • Matt, I moved things around in the program and changed which timer I was using and it now compiles. It doesn't oscillate yet and there seems to be some interference with other outputs I am using but I am working through it. I'll let you know how it goes.

    Thank you,
    Michael
  • Michael, I am glad to hear you made it past the compilation error and can move on to the next steps of the debug process!

    Best regards,
    Matt
  • Matt, I still can't get the timer to work inside of Captivate.  It works if I comment out the BSP_configureMCU() and the CAPT_appStart() lines. I have commented out all other instances of BIT0 in Captivate program(both found in CAPT_BSP.c and CAPT_BSP.h) with no success. I have included the problem code.  Where the timer code ends, I would normally go into some decision procedures which are commented out for now.  


    #include <msp430.h> // Generic MSP430 Device Include
    #include "driverlib.h" // MSPWare Driver Library
    #include "captivate.h" // CapTIvate Touch Software Library
    #include "CAPT_App.h" // CapTIvate Application Code
    #include "CAPT_BSP.h" // CapTIvate EVM Board Support Package
    #include "CAPTIVATE_PROXIMITY_Demo.h" // CAPTIVATE-PROXIMITY PCB Demo


    //*****************************************************************************
    // Function Implementations
    //*****************************************************************************
    #pragma PERSISTENT(RADIO_data1);
    unsigned long RADIO_data1=0X1FFF0;

    /////////////////////////
    int main(void)
    //void main(void)


    {
    WDTCTL = WDTPW | WDTHOLD; // Stop WDT

    //Configure GPIO
    P1DIR |= BIT0; // P1.0 output
    P1OUT |= BIT0; // P1.0 high

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

    TA1CCTL0 |= CCIE; // TACCR0 interrupt enabled
    TA1CCR0 = 550;
    TA1CTL = TASSEL__SMCLK | MC__UP; // SMCLK, UP mode

    __bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupt
    __no_operation(); // For debug
    }

    //Timer A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMER1_A0_VECTOR
    __interrupt void Timer_A (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER1_A0_VECTOR))) Timer_A (void)
    #else
    #error Compiler not supported!
    #endif

    {
    volatile uint32_t i;//TOGGLE FUNCTION
    WDT_A_hold(WDT_A_BASE);//TOGGLE FUNCTION

    // Initialize everything that is required for the demo.
    // The standard CAPTIVATE-FR2633 BSP is used to bring up the MCU.
    // The CAPTIVATE-PROXIMITY-Demo is setup with Demo_init(), which sets up
    // the LEDs and sensor callbacks. The CapTIvate application
    // is started with CAPT_appStart(), which calibrates the sensors and
    // configures the CapTIvate timer to provide the requested scan period.
    //
    WDTCTL = WDTPW | WDTHOLD;
    //BSP_configureMCU(); Timer does not start with this line--------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx---PROBLEM LINE
    __bis_SR_register(GIE);
    Demo_init();
    //CAPT_appStart(); Timer does not start with this line------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx---PROBLEM LINE

    ////////////////////////////////////////////////////////////////////////////////
    {
    P1OUT ^= BIT0;
    //TA1CCR0 += 600; // Add Offset to TACCR0, changed from 50000
    }
    ////////////////////////////////////////////////////////////////////////////////

    /**
    //
    // The CapTIvate application handler will refresh the user interface
    // when requested to by the CapTIvate timer flag. It will also handle
    // responding to communication on the I2C interface via the CapTIvate
    // protocol. If there is nothing left to do, the loop will sleep.
    //
    while(1)
    /////////////////////////////////////////
    {
    //LED3_OFF;

    ///////////////////////////////////////////

    //
    // Run the captivate application handler.
    // Set LED1 while the app handler is running,
    // and set LED2 if proximity is detected
    // on any sensor.

    Test1:
    if(CAPT_appHandler()==true) goto Framtest;//testing for touch
    if(CAPT_appHandler()==false)goto Standby;//no touch
    Framtest:
    if (RADIO_data1 == 0X1FFFF) goto Alarm_off;//testing for radio off signal
    //FRAM_data will change to incoming data from radio
    if (RADIO_data1 != 0X1FFFF) goto Alarm_on;//no radio off signal

    Alarm_off:
    {//LED3_OFF;
    LED2_ON;
    goto Test1;}

    Alarm_on:

    //////////////////////////////////////////////////////////////////////////////


    {//LED3_ON ^= BIT0;
    P1OUT ^= BIT0;
    //TA1CCR0 += 600;//} // Add Offset to TACCR0, changed from 50000


    ///////////////////////////////////////////////////////////////////////////

    //LED3_ON;
    for(i=1000000; i>0; i--);//LED OUTPUT TIME FUNCTION, decrementing
    LED2_OFF;
    while(i>0);

    goto Test2;
    }

    Test2:
    {
    if(CAPT_appHandler()==true) goto Framtest;
    if (RADIO_data1 == 0X1FFFF) goto Alarm_off;
    LED1_TOGGLE;
    for(i=100000; i>0; i--);
    LED3_OFF;
    goto Test2;
    }

    Standby:
    {//LED3_OFF;
    LED2_OFF;
    }


    // This is a great place to add in any
    // background application code.

    __no_operation();

    //
    // End of background loop iteration
    // Go to sleep if there is nothing left to do

    CAPT_appSleep();

    } **/// End background loop
    } // End main()

    Any help would be greatly appreciated.  If I can't get this to work from the processor I will just trigger a comparator/oscillator on another chip but seems like this should be doable.  The nomenclature used for the Timers is a bit confusing by the way.  

  • Michael,

    The CapTIvate peripheral has its own dedicated internal timer, so there should not be an issue using any of the timers available to you on the device, granted that nothing else in your application is using it. The function BSP_configureMCU() overwrites any GPIO settings previously selected so be sure that the BSP_configureMCU() function is called before setting up any of the other GPIOs in your application.

    It is very difficult to understand the code flow in the format you provided the source code. Could you either attach a zip file of the project or use the "Insert code" tool on E2E to provide the source code?

    Best regards,

    Matt
  • Pretty much your entire program is executed in a timer ISR. Since you haven't turned off the timer (TA1) and you re-enable interrupts, this "program" will restart every 550 microseconds. My guess is that this isn't long enough to do much.

    I recommend you move all that code into main(). What did you intend for the timer to do?
  • Michael,

    Did Bruce's answer help point you in the right direction of solving your problem?

    Best regards,

    Matt
  • Matt, I haven't actually worked on it again for a bit.  The project also includes a CC1310 which I have been also working on.  Interesting point but I was able to get the CC1310 to do what I wanted to do in the MSP430FR2633 in regards to the timer function so I may not need to go that route.  Not sure yet how it is going to work out because I am not quite finished with the radio code.

    Thanks and I'll let you know if I run into more trouble or learning opportunities.  

  • Michael,

    Okay sounds good! Feel free to reach out with any MSP430 related questions or problems you run into.

    Best regards,

    Matt
  • Hello Michael,

    I'm glad that you got the timer function referenced in your initial post up and running. Since the initial problem seems to be resolved, please go ahead and select "Resolved" so that we can close out this specific thread. As I mentioned before, please feel free to reach out using a new post with any MSP430 questions or problems.

    Best regards,

    Matt Calvo

**Attention** This is a public forum