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.

MSP432 Stop RTC

Hi all, i'm writing a simple example to use RTC interrupt. This part works and i haven't problems (i'm trying this with a blinking led for example 1 second on, 1 second off...).

My question is: when rtc starts, is there a method to stop it? So that the counter loop stops and, in this case, led stops blinking.

Thanks Luca

  • Hey Luca,

       I believe that you are looking for the Hold bit in the RTC control register, RTCHOLD in RTCCTL1.  Be sure to access the key/unlock the peripheral before attempting to modify this register.  Let me know if you have additional questions.

    http://www.ti.com/lit/pdf/slau356

    http://www.ti.com/lit/ug/slau356d/slau356d.pdf#page=637

    Regards,
    Chris

  • My example is this:

    #include "msp.h"
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <math.h>
    
    void set_rtc(char *date){
    	RTCCTL0_H = RTCKEY_H;                       //   Unlock RTC key protected registers
    	RTCYEAR = strtol(&date[ 0], NULL, 16);
    	RTCMON  = strtol(&date[ 5], NULL, 16);
    	RTCDAY  = strtol(&date[ 8], NULL, 16);
    	RTCHOUR = strtol(&date[11], NULL, 16);
    	RTCMIN  = strtol(&date[14], NULL, 16);
    	RTCSEC  = strtol(&date[17], NULL, 16);
        RTCCTL0_H = 0;                              //   Lock RTC key protected registers
    }
    
    void main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;           // Stop watchdog timer
        P1DIR |= BIT0;                      // Configure P1.0 as output (rosso)
        P1OUT &= ~BIT0;
    
    	// ==========Configurazione Real Time Clock==========
        RTCCTL0_H = RTCKEY_H;                    // Unlock RTC key protected registers
        RTCPS1CTL |= RT1PSIE;					 // Interrupt disable
        RTCPS1CTL |= RT1IP_4;					 // 0.5 seconds
        RTCPS1CTL &= ~(RT1PSIFG);
        RTCCTL1 = RTCBCD | RTCHOLD;              // BCD select (calendar register), RTCHOLD counters and prescale counters actived
        // RTC enable, BCD mode, RTC hold
        // enable RTC read ready interrupt
        // enable RTC time event interrupt
        RTCCTL1 &= ~(RTCHOLD);                    // Start RTC calendar mode
        RTCCTL0_H = 0;                            // Lock the RTC registers
    
        NVIC_ISER0 = 1 << ((INT_RTC_C - 16) & 31);
    
        SCB_SCR |= SCB_SCR_SLEEPONEXIT;    // Enable sleep on exit from ISR
        __enable_interrupt();
    
    	set_rtc("2000-01-01 00:00:00");		// Set rtc
    }
    
    // RTC interrupt service routine
    void RtcIsrHandler(void)
    {
        if (RTCPS1CTL & RT1PSIFG)
        {
        	P1OUT ^= BIT0; //
        }
        RTCCTL0_H = RTCKEY_H ;
    	RTCPS1CTL &= ~RT1PSIFG;
    	RTCCTL0_H = 0;
    }

    If i want stop the blinking led after rtc starts (for example after N led_on/led_off), what is the command? could you write me a simple example?

    Thanks

  • Luca,
    For example in the ISR where you unlock the RTC, clear the IFG , and then lock the RTC, you can insert a line that sets the RTCHOLD bit similar to what you do in line 29.

    Sorry, apparently my earlier link was broken:
    www.ti.com/.../slau356d.pdf

    Regards,
    Chris

**Attention** This is a public forum