SLAAEN0 September 2024 MSPM0L1227 , MSPM0L1227-Q1 , MSPM0L1228 , MSPM0L1228-Q1 , MSPM0L2227 , MSPM0L2227-Q1 , MSPM0L2228 , MSPM0L2228-Q1
This example needs two Tamper I/O configurations. Configure Tamper I/O 0 as input to act as a tamper event trigger. The timestamp event output captures the event occurrence and RTC records when the event is captured. Next, configure Tamper I/O 1 as output to toggle LED for Heartbeat mode. As the Tamper I/O triggered the rising edge, the TSCTL register captures the first or last event that occurred. The configured LED remains flashing as VDD power loss to show that the heartbeat generator is still functioning and is supplied by VBAT.
#include "ti_msp_dl_config.h"
volatile bool gCheckTSEVT = false;
volatile uint32_t counter = 0;
volatile uint8_t gBlink;
int main(void)
{
/* Initialization */
SYSCFG_DL_init();
/* Enable the RTC interrupt at NVIC */
NVIC_EnableIRQ(RTC_A_INT_IRQn);
/* Start RTC clock */
DL_RTC_A_enableClockControl(RTC_A);
while (1) {
__WFI();
/* Wait in a while() loop until the time stamp interrupt triggers - Trigger a tamper event externally */
while (gCheckTSEVT == false)
;
/* Blink LED a number of times equal to amount of time stamp events detected */
if (DL_RTC_A_getTimeStampEventCause(
RTC_A, DL_RTC_A_TIME_STAMP_EVENT_CAUSE_TIO_0) ==
DL_RTC_A_TIME_STAMP_EVENT_CAUSE_TIO_0) {
for (gBlink = 0; gBlink < (2 * counter); gBlink++) {
DL_GPIO_togglePins(GPIO_LEDS_LED_2_PORT, GPIO_LEDS_LED_2_PIN);
delay_cycles(16000000);
}
}
}
}
void LFSS_IRQHandler()
{
switch (DL_RTC_A_getPendingInterrupt(RTC_A)) {
case DL_RTC_A_IIDX_TSEVT:
counter++;
gCheckTSEVT = true;
default:
break;
}
}