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/MSP-CAPT-FR2633: CCS/MSP-CAPT-FR2633

Part Number: MSP-CAPT-FR2633

Tool/software: Code Composer Studio

Hi,

Before I describe my problem, I will explain how I got there. I am developing a product that requires capacitive touch. I have generated code from the captivate design center to trigger an LED on the dev board as a starter. Then I made a version to not use UART or Bulk_I2C with PC, therefore standalone turn on the onboard LED upon touching a CAPTIVATE-BSWP pad button. Also changed the clock to 16MHz. It detected touch in the while loop, perfect!

Next I added code software that drives a WS2812 based RGB LED strip. It has a timer interrupt that ticks a counter. In the continuous loop a function checks if the timer ticks are greater than or equal to a particular amount, and outputs a pattern to the LED Strip via UCA0TXBUF of UCA0SIMO in SPI mode. Next I implemented a capacitive touch to trigger the start of this application, like an on button. So in the main(), after performing the initialisation functions of the RGB LED strip and and Capacitive module, and before entering the while(1) continuous loop, I have

CAPT_appStart();                                            

CAPT_appSleep();                                       

While(CAPT_appHandler() != true);             // wait till button is pressed to proceed.

START_TIMERA2;                                             // vector=TIMER2_A0_VECTOR                  Timer 2 A2 CC0

 while(1)

{

    RGB_LED_Pattern();                            // Output pattern to WS2812 RGB LED strip

}

On detecting a touch, it proceeds to run the LED strip pattern in the loop. My problem is, if I add capacitive sensing in the while(1) loop (see below) it will run once and halt. As a side note, I noticed timer interrupts are still running in TIMER2_A0_VECTOR ISR when I put a break point.

while(1)

{

     if(CAPT_appHandler() == true)         //if touch is detected

     {

            LED1_ON;                                      // turn on board LED

            __no_operation();

      }

      else LED1_OFF;

      RGB_LED_Pattern();                           //Output pattern to WS2812 RGB LED strip

}

What is confusing is if I take my LED routine out of the while loop and just keep the capacitive touch check, the capacitive touch responds and loops to keep checking.

I have narrowed down that something happens in CAPT_updateUI(&g_uiApp) in CAPT_appHandler() function which I call in the while(1) loop, but I am unable to solve this and couldn’t understand why I can’t run both my LED function and CAPT_appHandler() check in the continuous loop. It may be a low power mode issue that is a simple fix, which I couldn't find in the CapTIvate Design Center generated code. Anyone who could help me solve this, I appreciate it. Thank you in advance!

  • Hi Guyan,

    Do you mean that the code is halted in the TIMER2_A0_VECTOR ISR? Or any other place?

    Can you share your code of the TIMER2_A0_VECTOR ISR and RGB_LED_Pattern(); ?
  • Hi Wei,

    Thank you very much for replying. The code isn't halted in the Timer ISR. It runs timer ISR and ticks as it's supposed to because I put a breakpoint in the beginning and end of the Timer ISR and checked. However in the while(1) loop in main, it has run RGB_LED_Pattern function once and stopped, because I can see just one LED on and frozen.

    I have copied and pasted the 2 pieces of code you requested. The RGB_LED_Pattern function has two other functions mentioned in it, which I will also paste at the bottom. Especially because one of them disables and re-enables interrupts.

    //=====================================================================================
    // 2 LEDs moving across - placed in while(1) in main
    //=====================================================================================
    void RGB_LED_Pattern(unsigned int sunLight)
    {
    if(timer2_A2_Ticks >= WIPE_SPEED)
    {
    char j; //Each LED index in combination
    for(j = 0; j < NUM_LEDS; j++)Set_LED_Colour(j, 0x00, 0x00, 0x00); //Clear all LEDs
    Set_LED_Colour(white_LED_Pos, 0xF0, 0xF0, 0xF0); //Set 2 white LEDs
    Set_LED_Colour(white_LED_Pos-1, 0xF0, 0xF0, 0xF0);

    if(--white_LED_Pos <= 0) white_LED_Pos = NUM_LEDS; // reset position to highest LED
    Send_And_Show_Strip();
    timer2_A2_Ticks = 0; // reset timer ticks
    }

    }


    //=======================================================================================
    // Interrupt vector for the timer that determines the LED movement speed
    //=======================================================================================
    #pragma vector=TIMER2_A0_VECTOR // Timer 2 A2 CC0
    __interrupt void TIMER2_A0_ISR(void)
    {
    TA2CCTL0 &= ~CCIFG; // clear interrupt flags
    TA2CTL &= ~TAIFG;

    timer2_A2_Ticks++; // Increment timer ticks in ISR

    TA2CTL |= TACLR | MC1 | TASSEL__SMCLK; //clear timer , source from SMCLK, start counting
    TA2CCTL0 |= CCIE; // enable interrupts again
    TA2CTL |= TAIE;

    return;
    }



    The two other functions that are called in the RGB_LED_Pattern function are below, in case you wanted to refer to them:

    void Set_LED_Colour(unsigned int n, char r, char g, char b)
    {
    leds[n].green = g;
    leds[n].red = r;
    leds[n].blue = b;
    }

    void Send_And_Show_Strip(void)
    {
    __bic_SR_register(GIE); // Clear global interrupts

    //Set RGB colour of each LED
    unsigned char i,j;
    for(i = 0 ; i < NUM_LEDS; i++)
    {
    char *rgb = (char*)&leds[i]; // Get GRB colour combination for the LED in this position
    for (j = 0; j < 3 ; j++) // Send combination in the order green-red-blue

    {
    char mask = 0x80;
    while(mask != 0)
    {
    while(!(UCA0IFG & UCTXIFG)); // Wait before transmit. Writing to the UCB0TXBUF clears UCTXIFG
    if(rgb[j] & mask) // Check 8th bit first, then 7 6 5 ... 1 0 , MSB first
    {
    UCA0TXBUF = HIGH_CODE; // Send 1
    }
    else
    {
    UCA0TXBUF = LOW_CODE; // Send 0
    }
    mask = mask >> 1; // Move on to next bit and check
    }
    }
    }
    _delay_cycles(800); //Send RES code for at least 50us as datasheet says
    __bis_SR_register(GIE); // Clear global interrupts
    }
  • Hi Wei,

    Did you have any luck with this problem yet?

    Kind regards,

    Guyan

**Attention** This is a public forum