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.

MSP430FG4619--RTC

hello professors,

Now, i can successfully use the RTC module which has hour, minute, second part. But there is no miliseconds part in this module. So if I want to display the miliseconds on the screen, what can I do it? Do you have some suggestions? really thankful for your time.

Thanks again

Best regards 

  • The RTC is based on 32768Hz clock, which won’t divide well into 1/1000s (but divides well with a simple binary divider). You won’t get ms resolution form the RTC.

    I use a timer for my 1ms count. The timer runs from a 1MHz clock and on each interrupt (every 1000 timer ticks), the ms counter is incremented.
    To stay synchronous to the calibrated RTC, I check the passed time for RTC and ms timer every now and then, and adjust the timer tick count to 999 or 1001 if I’m behind or ahead the RTC.

  • Hello professor,

    now, I take your advice to use timer module to test, but I found the code cannot jump out of the interrupt, could you help me to have a look about my configuration?  Is there something wrong in it? thanks so much for your time

    void Init_TIMERA0(void)
    {
      TA0CCR0 = 1000;  //count limit (16 bit) 12000
      TA0CCTL0 = CCIE;  //enable counter interrupts, bit 4=1, TACCR0 interrupt enabled
      TA0CTL = TASSEL_2 + MC_1;  //SMCLK
     
    }


    #pragma vector = TIMER0_A1_VECTOR
    __interrupt void Timer0_A1 (void)
    {
      Time_miliseconds();
      //timer++;
    }

    #pragma vector = TIMER0_A0_VECTOR
    __interrupt void Timer0_A0 (void)
    {
      //Time_miliseconds();
      //timer++;
      asm("nop");
    }

    int main( void )
    {
        WDTCTL = WDTPW + WDTHOLD;
       InitFreq_XT2();
       Init_TIMERA0();
       __bis_SR_register(GIE);
    while(1)
    {
      DrawMenu();   //the pointer stops here and it cannot go down anymore
    ..........
    .........
    }
    }

  • The interrupt for TA0CCR0 jumps to TIMER0_A0_VECTOR.
    All other interrupts of TimerA0 jump to TIMER0_A1_VECTOR.

    However, you'll need to manually clear the IFG bits for those other interrupts. Only CCIE in TA0CCR0 clears by itself (as it is the only trigger for this interrupt).
    If you doN't clear the IFG bits (whether directly, or by reading the TA0IV register), the ISR will be called over and over again and main execution will effectively stop.

    But the code you posted should call TIMER0_A0_VECTOR ISR and execute the nop in it.

    What does InitFreq() do? Or TimeMilliseconds()? (BTW: it is not the best idea to call functions form within an ISR. It adds lots of overhead, and perhaps the function does something that stalls the system (if it isn't aware that it is called form within an ISR)

**Attention** This is a public forum