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.

MSP430FR2355: RTC

Part Number: MSP430FR2355

Hello team,

I want to send RTC along with 100bytes of data from one msp430fr2355 to other msp430fr2355 through UART.

Now need to capture the RTC at last byte in first msp430 and again capture RTC at first byte reception in second msp430. finally i want to know time taken to receive first and last byte to second msp430. Can anyone help me to implement this would be very thankful. below is the RTC code  

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

    P2SEL1 |= BIT6 | BIT7;                  // P2.6~P2.7: crystal pins
    do
    {
        CSCTL7 &= ~(XT1OFFG | DCOFFG);      // Clear XT1 and DCO fault flag
        SFRIFG1 &= ~OFIFG;
    }while (SFRIFG1 & OFIFG);               // Test oscillator fault flag

    P1OUT &= ~BIT0;                         // Clear P1.0 output latch for a defined power-on state
    P1DIR |= BIT0;                          // Set P1.0 to output direction

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


    // RTC count re-load compare value at 32.
    // 1024/32768 * 32 = 1 sec.
    RTCMOD = 32-1;
                                            // Initialize RTC
    // Source = 32kHz crystal, divided by 1024
    RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1024 | RTCIE;

    __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3, enable interrupt
}

// RTC interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(RTC_VECTOR))) RTC_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(RTCIV,RTCIV_RTCIF))
{
case RTCIV_NONE: break; // No interrupt
case RTCIV_RTCIF: // RTC Overflow
P1OUT ^= BIT0;
rtc++;                                               ////// i need to send this rtc(unsigned long int) value to next msp430. 
break;
default: break;
}
}

  • Hi,

    We don't coding on e2e. If you meet any typical problem, I am willing to help.

    I think what you need is to combine UART code example and RTC code example together.

    Eason

  • Thank you for the reply,

    I'm trying to add time stamp for both msp430fr2355. For that i need to start timer whenever i press a particular key so that i can know time based on counts, If i call timer enable function in GPIO ISR will it work ?

    is it possible to call timer function in GPIO ISR? If possible, help me how to reset that timer in both msp430fr2355 with one switch for the next time.

    below is the code i have implemented.

    // Port 4 interrupt service routine
    #pragma vector=PORT4_VECTOR
    __interrupt void Port_4(void)
    {
    P4IFG = 0; // Clear all P4 interrupt flags
    P2OUT |= BIT1; // to wake up second controller

    timer_init();      // This is the timer interrupt function for every 20 micro seconds.

    }

    //Timer0_B0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMER0_B0_VECTOR
    __interrupt void Timer0_B0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER0_B0_VECTOR))) Timer0_B0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {

    count++;

    }

  • Yes, you can. Actually I think you can handle it by referring to our example code.

    You can try this one:

    TB0CCTL0 |= CCIE; // TBCCR0 interrupt enabled
    TB0CCR0 = 20000;
    TB0CTL |= TBSSEL__SMCLK | MC__CONTINUOUS; // SMCLK, continuous mode

    __bis_SR_register(GIE); // Enter LPM3 w/ interrupts

  • Thank you,

    TB0CCR0 = 20000; is this for 20 micro second interrupt?

    and one more can you describe me in detail to reset timer in remaining two msp430fr2355 for next time attempt? do i miss any steps to reset timer from below timer_init code ?

    void timer_init()
    {
        TB0CCTL0 |= CCIE;                         // TBCCR0 interrupt enabled
        TB0CCR0 = SMCLK_FREQUENCY / 100000UL;     // 20usec timer interrupt
        TB0CTL = TBSSEL__SMCLK | MC_1;            // SMCLK, Up mode
        __bis_SR_register(GIE);               // To Enter interrupt
    }

     

  • Yes, I think your SMCLK is 1MHz. 20000/1MHz = 20ms

    Add this one:

    TB0CTL = TBCLR; //stop timer and clear counter
    TB0CCTL0 &= ~(CCIFG);

**Attention** This is a public forum