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-EXP430FR2355: Issue with given Timer example in msp430ware working with MSP-EXP430FR2355

Part Number: MSP-EXP430FR2355

Tool/software: Code Composer Studio


Hi,

I'm a beginner of TI architecture so can't figure out what mistake happened at __bis_SR_register(LPM4_bits | GIE);
in any code example with
__bis_SR_register(_any LPM mode) 

make code to struct at that line forever. I tried all LPM modes but nothing helpfull.
If i remove the LPM mode bits
__bis_SR_register(GIE); 
this works fine. but below example won't work without LPM mode so, please someone help me to resolve this issue.


Hardware: MSP-EXP430FR2355 launchpad
Software: MSP430WARE --> msp430fr235x_tb0_22.c


// example: msp430fr235x_tb0_22.c


#include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT // Configure GPIO P1DIR |= BIT0; P1OUT = 0; P2SEL0 |= BIT7; // P2.7 selected as TB0CLK // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Configure Timer_B TB0CTL = TBSSEL_0 | MC_2 | TBCLR | TBIE; // ACLK, count mode, clear TBR, enable interrupt TB0R = 0xFFFF - 20; // Offset until TBR overflow __bis_SR_register(LPM4_bits | GIE); // Enter LPM4, enable interrupts __no_operation(); // For debug while (1) { P1OUT ^= BIT0; // P1.0 = toggle __bis_SR_register(LPM0_bits); // CPU is not required } } // Timer0_B3 Interrupt Vector (TBIV) handler #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=TIMER0_B1_VECTOR __interrupt void TIMER0_B1_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(TIMER0_B1_VECTOR))) TIMER0_B1_ISR (void) #else #error Compiler not supported! #endif { switch(__even_in_range(TB0IV,TB0IV_TBIFG)) { case TB0IV_NONE: break; // No interrupt case TB0IV_TBCCR1: break; // CCR1 not used case TB0IV_TBCCR2: TB0CCR2 += 50000; // Add Offset to TBCCR1 __bic_SR_register_on_exit(LPM0_bits);// CPU active on reti break; // CCR2 not used case TB0IV_TBIFG: // overflow TB0CTL = TBSSEL_2 | TBCLR; // SMCLK, clear TBR TB0CCTL2 = CCIE; // TBCCR1 interrupt enabled TB0CCR2 = 50000; TB0CTL |= MC_2; // Start Timer_B in continuous __bic_SR_register_on_exit(LPM4_bits);// Exit LPM4 on reti break; default: break; } }



  • This example supposes that you have a clock input signal connected to the P2.7 pin. Do you have that?

    If you just want to see it run first, you could change the TB0 clock from "external" to ACLK and use LPM3 instead of LPM4 (ACLK doesn't run in LPM4):

    >TB0CTL = TBSSEL_0 | MC_2 | TBCLR | TBIE;

    becomes

    >TB0CTL = TBSSEL_1 | MC_2 | TBCLR | TBIE;

  • Thank you Bruce,

    Now it's working with ACLK.

    Actually P2.7 is connected to external crystal 32Khz on launchpad. can that be considered as external clock ?

  • I haven't tried it, but I'm pretty sure the answer is No. In order to get the crystal to oscillate you need to connect XIN/XOUT to the oscillator circuit in the MCU by setting P2SEL=10 [Ref Data Sheet (SLASEC4C) Table 6-64], which would prevent your using it as TB0CLK (P2SEL=01).

    What I have done in the past when I wanted to test/demonstrate an external timer clock is to use a second timer to generate a square wave (50% duty PWM) and then run a patch wire from that pin to the timer clock input pin. You wouldn't be able to do that with TB0 on the Launchpad since (as far as I can tell) there's no P2.7 pin. TB1CLK is on P2.2, which would be a possibility.

    We're only talking about maybe 15 lines of code, but I suspect it's more new stuff than you originally signed up for. What's your longer-term goal? I'm wondering if you just want a different Example.

  • Thank you Bruce,

    Really your explanation cleared a lot of things to me.

    My mistake didn't realized that P2.7 PIN configuration SET to TB0 clock.

    My final goal is :

    Actually i'm trying to make a Timer tick interrupt for every 1 micro second which should initiate a transmit UART send to other MSP430 at a baud of 1Mbps exactly at 22.5 milli seconds after detecting a raising edge on a DIO. Did i make it complicated?

    let me explain again in steps

    1. There should be Timer interrupt at 1 micro second containing  UART send configured at 1Mbps.

    2. MSP430 is waiting for a DIO raising edge interrupt.

    3. Once the interrupt is detected we should initiate UART send exactly after 22.5 milli seconds.

    In this, 

    I done

    DIO rising edge interrupt.

    Sending UART data @0.4Mbps but is it possible to configure for 1Mbps?

    Timer interrupt i'm studying now but i'm confused of clock sources and Low power modes.

    This is my final goal but i'm still learning.

  • I'm fine with (2)-(3) but I'm not sure where the 1-usec UART send in (1) fits in. Trying to get an actual interrupt every 1-usec is infeasible, even at 24MHz, since a simple ISR takes 20-30 CPU clocks (out of a possible 24). 

    A UART byte takes 10 bits, so at 1Mbps it takes 10usec (minimum) to send a byte. I think it's possible to drive the UART at 1Mbps (I haven't tried it on an FR2355). As you speed up the UART (i.e. as BRW decreases) the wire will see more of the clock jitter, which may (or may not) bother whatever is at the other end. Short answer: Try it and see what you get.

  • Hello Bruce,

    I have referred (slau445i) given BRCLK upto 20000000 and baud rate 460800, But i want  Baud rate 1Mbps for 24Mhz clock.

    Please help me to configure Clock and setting baud rate for above requirement.

    Thank you  

  • BRW is a simple divisor from BRCLK. For BRCLK=SMCLK=24MHz, setting BRW=24, UCOS16=0, and MCTLW=0 should give you 1Mbps.

  • Thank you Bruce,

    Great, Now UART is running with 1Mbps.

**Attention** This is a public forum