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.

MSP430FR6922: RTC :1 second calculations

Part Number: MSP430FR6922

Hello All,

   I am working on MSP430FR6922 controller RTC module. I am using RTC_C module.Want to generate interrupt at every 1 sec using RTC module.I have taken sample code of RTC from resource explorer "">dev.ti.com/.../node

Can someone explain me in detailed how 1 sec interrupt is generated. Please elaborate calculations ...

Thanks

  • Hi Sayali,

    In this example, the RTC_C peripheral is in counter mode, and is set to trigger an event at 8-bit overflow or 256 counts.

    Your ACLK is 32768Hz, which is divided by 8 using the Timer 0 divider, and then again by 16 using the Timer 1 divider. This is used as the input clock for the RTC based on the RTCSSELx bit in the RTCCTL1 register. 

    So 32768Hz/8/16 = 256 Hz. So in order to trigger the 8-bit overflow event, you would need 256 counts/256Hz or 1 second. 

    Best Regards,
    Brandon Fisher

  • Thanks you so much Bradon.. 

    So, now if I want to generate interrupt at every 0.125 second my calculations are as follows:-

    ACLK=32768/8/2=2048...So, for an 8-bit overflow 256 count/2048Hz= 0.125 second

    is this correct??

    I have attached code for reference:-

    -

    void RTC(void)
    {
        // Setup RTC Timer
         RTCCTL0_H = RTCKEY_H;                   // Unlock RTC
    
        // RTCCTL0_L = RTCTEVIE;                   // RTC event interrupt enable
         RTCCTL1 = RTCSSEL_2 | RTCTEV_0 | RTCHOLD; // Counter Mode, RTC1PS, 8-bit ovf
         RTCPS0CTL = RT0PSDIV1;                  // ACLK, /8
         RTCPS1CTL = RT1SSEL1 | RT1PSDIV_0; // out from RT0PS, /2
    
         RTCCTL1 &= ~(RTCHOLD);                  // Start RTC
      }
    
    
    #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_RT1PSIFG))
        {
            case RTCIV_NONE:      break;        // No interrupts
            case RTCIV_RTCOFIFG:  break;        // RTCOFIFG
            case RTCIV_RTCRDYIFG: break;        // RTCRDYIFG
            case RTCIV_RTCTEVIFG:               // RTCEVIFG
                count++;
    
                if(count==8)
                {
                    second++;
                    count=0;
                }
    
    //           if(count==FinalDelaytime)
    //           {
    //               //timer stop
    //               TA0CCTL0 &= ~CCIE;
    //               //rtc disabled
    //               RTCPS1CTL &= ~RT1PSIE;
    //
    //               P7OUT&=~ BIT0;                // Relay off
    //           }
                 break;
            case RTCIV_RTCAIFG:   break;        // RTCAIFG
            case RTCIV_RT0PSIFG:  break;        // RT0PSIFG
            case RTCIV_RT1PSIFG:  break;        // RTCRDYIFG
            default: break;
        }
    }

  • Hi Sayali,

    Yes that should work. 

    Best Regards,
    Brandon Fisher

  • Thanks a lot Brandon...This resolved my issue

**Attention** This is a public forum