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.

MSP430FR5972: Delay using Timer

Part Number: MSP430FR5972

MSP430FR5972, CCS v7

Hello I need help to generate delay using Timer without ISR but Timer should be use in a single program the functions are

TA0 - Stimulation LED blinking
TA1 - Battery LED blinking
TA2 - ADC sampling
TA3 - Delay timer 100 mS delay)
TB0 - used Delay for Button Debounce 
Plz suggest me or provide some sample code in which TA0, TA1, TA2, TA3 & TB0 used.
  • Just wait for the corresponding IFG bit to be set. What exactly is the problem?
  • I just need to write a program for delay but in my program TA0, TA1, TA2, TA3 & TB0 used separately function. Because I need to use all of these timer for different peripheral
  • You said TA3 is a delay timer. Do you mean that you cannot use any of those timer modules?

    Can't you use another CCR of one of those timers?

    Are you using the watchdog timer?
  • Hi Clemens thanks for reply actually I am new in MSP430 so I unable to access Timer feature
    No I am not using watchdog
  • It is possible to use multiple CCRs of the same timer module to get different intervals. See section 19.2.2.3 of the User's Guide.
  • Hi Clemens I would be very thankful if you send me any demo code b'coz in the example code there is only one timer used at a time
  • See the application report Multiple Time Bases on a Single MSP430 Timer Module (SLAA513).

  • I just Develop the code for 10 sec delay by the help of some example code but it is not run proper 10 sec (run near about 8 sec )
    I am not using any crystal osc. Code is below. plz guide me or do change where you feel to change...

    #include <msp430.h>
    #include "stdint.h"

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

    // Configure GPIO
    P1DIR |= BIT0;
    P1OUT |= BIT0;

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

    TA0CCTL0 = CCIE; // TACCR0 interrupt enabled
    TA0CCR0 = 32768;

    TA0CTL = TASSEL_1 | ID_0 | MC_2; // ACLK, divider 1, continuous mode, clear

    //TA0CTL = TASSEL__SMCLK | MC__CONTINOUS; // SMCLK, continuous mode

    __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
    __no_operation(); // For debugger
    }
    // Timer0_A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMER0_A0_VECTOR
    __interrupt void Timer0_A0_ISR (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer0_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    static uint8_t counter = 0; // Variable for counting multiples of 1 second

    TA0CCR0 += 32768; // Add another second

    if( ++counter >= 10 ) // 10 seconds elapsed
    {
    P1OUT ^= P1OUT; // Toggle LED
    counter = 0; // Reset counter
    }
    }
  • Even I also use this code for 5 sec but not working (it works for around 4.3 sec). code are below :


    #include <msp430.h>
    #include "stdint.h"

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

    // Configure GPIO
    P1DIR |= BIT0;
    P1OUT |= BIT0;

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

    TA0CCTL0 = CCIE; // TACCR0 interrupt enabled
    TA0CCR0 = 20479;

    TA0CTL = TASSEL_1 | ID_3 | MC_2; // ACLK, divider 1, continuous mode, clear

    __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
    __no_operation(); // For debugger
    }
    // Timer0_A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMER0_A0_VECTOR
    __interrupt void Timer0_A0_ISR (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer0_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    TA0CCR0 += 20479; // Add another second
    P1OUT ^= P1OUT; // Toggle LED
    }

    plz reply

  • hi clemens, Plz reply something I am waiting
  • Section 3.2 of the User's Guide says:

    … the CS module default configuration is:
    LFXT is selected as the oscillator source for LFXTCLK. LFXTCLK is selected for ACLK (SELAx = 0) and ACLK is undivided (DIVAx = 0).

    […] but LFXT is disabled. […] the fault control logic immediately causes ACLK to be sourced by LFMODCLK

    And LFMODCLK is 5 MHz / 128 = 39 kHz, which would result in a delay of 4.2 s, which is exactly what you're seeing. (And MODCLK isn't too accurate to begin with.)

    If you want to use a 32.768 kHz clock, you have to correctly start up the crystal. (See the example programs for how to do this.)

**Attention** This is a public forum