hy guys I start work with the RTC module and therefore I tested the code of the TI side (see below).
//******************************************************************************
// MSP432P401 Demo - RTC in real time clock mode
//
// Description: This program demonstrates the RTC mode by triggering the event
// interrupt RTCRDYIE event, which triggers every minute change. P1.1 toggles
// every minute to indicate this interrupt.
// After configuring the RTC, device goes into LPM3 and waits for the RTC interrupts.
// Notice that RTC starting second is set to be 45, so after starting the program
// the first RTC interrupt should trigger after ~15 seconds. Consequent interrupts
// should occur every minute.
// This code recommends an external LFXT1 crystal for RTC accuracy.
// ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
//
// MSP432p401rpz
// -----------------
// /|\ | XIN|-
// | | | 32kHz
// ---|RST XOUT|-
// | |
// | P1.0 |--> Toggles every minute
// | |
//
//
// Dung Dang
// Texas Instruments Inc.
// November 2013
// Built with Code Composer Studio V6.0
//******************************************************************************
#include "msp.h"
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
/* Configure P1.0 LED */
P1DIR |= BIT0 ;
P1OUT &= ~( BIT0 );
// Configure RTC
RTCCTL0_H = RTCKEY_H ; // Unlock RTC key protected registers
RTCCTL0_L |= RTCTEVIE ;
RTCCTL0_L &= ~(RTCTEVIFG);
RTCCTL1 = RTCBCD | RTCHOLD ;
// RTC enable, BCD mode, RTC hold
// enable RTC read ready interrupt
// enable RTC time event interrupt
RTCYEAR = 0x2010; // Year = 0x2010
RTCMON = 0x4; // Month = 0x04 = April
RTCDAY = 0x05; // Day = 0x05 = 5th
RTCDOW = 0x01; // Day of week = 0x01 = Monday
RTCHOUR = 0x10; // Hour = 0x10
RTCMIN = 0x32; // Minute = 0x32
RTCSEC = 0x45; // Seconds = 0x45
RTCADOWDAY = 0x2; // RTC Day of week alarm = 0x2
RTCADAY = 0x20; // RTC Day Alarm = 0x20
RTCAHOUR = 0x10; // RTC Hour Alarm
RTCAMIN = 0x23; // RTC Minute Alarm
RTCCTL1 &= ~(RTCHOLD); // Start RTC calendar mode
RTCCTL0_H = 0; // Lock the RTC registers
/* Enable all SRAM bank retentions prior to going to LPM3 (Deep-sleep) */
SYSCTL_SRAM_BANKRET |= SYSCTL_SRAM_BANKRET_BNK7_RET;
__enable_interrupt();
NVIC_ISER0 = 1 << ((INT_RTC_C - 16) & 31);
SCB_SCR |= SCB_SCR_SLEEPONEXIT; // Sleep on exit from ISR
while (1)
{
/* Setting the sleep deep bit */
SCB_SCR |= (SCB_SCR_SLEEPDEEP);
__sleep();
/* Clearing the sleep deep bit */
SCB_SCR &= ~(SCB_SCR_SLEEPDEEP);
}
}
// RTC interrupt service routine
void RtcIsrHandler(void)
{
if (RTCCTL0 & RTCTEVIFG)
{
P1OUT ^= BIT0;
RTCCTL0_H = RTCKEY_H ;
RTCCTL0_L &= ~RTCTEVIFG;
RTCCTL0_H = 0;
}
}
All works great, but I don't understand how the interrupt got called every minute when the RTCAMIN register was set to 0x23 (23) and not 1.
Maybe anyone can help me ?