Hi Bob,
Thanks for the reply,
I've looked, and as hoped, found the weak linkages, here's the one for the RTC:
WEAK_AV void RTC_IRQHandler(void)
{ RTC_DriverIRQHandler();
}
When I have my custom RTC_IRQ commented out , that function points towards:
WEAK_AV void IntDefaultHandler(void)
{
while(1) {}
}
I have over-ridden the RTC_IRQHandler, with my code, but I don't know either way, if it's being hit.
I noticed that your example had:
“void LPUART0_IRQHandler( void ) __attribute__( ( used, naked, interrupt( "IRQ" ) ) );”
Could you explain what this is meant to be doing, my IRQ’s don’t have this, could this be what is wrong?
I tried using the debugger to "catch" the code at the while(1) point of the code (with the RTC IRQ Disabled) , but it didn’t work, my guess is that when it's going to sleep it's "disconnecting" from the debugger, so not working.
I've tried using the debugger to pin-point likely issues, but when using the debugger around sleep, I find that I'm getting errors, my guess is that the debugger is trying to talk to an MCU that's asleep and having issues with that.
I've also tried running the code stand-alone, without the debugger connected, which didn’t fix it either.
In the reference manual, I've found the following :
"Going into a VLLSx mode causes all the debug controls and settings to be reset.
To give time to the debugger to sync up with the HW,
the MDM-AP Control register can be configured to hold the system in reset on recovery so that the debugger can regain control and reconfigure debug logic prior to the system exiting reset and resuming operation."
Do you think it's possible that this is the state that it's getting stuck in?
I've also looked at some of the VLLS documentation:
"18.5.2 VLLS modes"
"For any wakeup from VLLS, recovery is always via a reset flow and
RCM_SRS[WAKEUP] is set indicating the low-leakage mode was active. State retention
data is lost and I/O will be restored after PMC_REGSC[ACKISO] has been written.
A VLLS exit event due to RESET pin assertion causes an exit via a system reset. State
retention data is lost and the I/O states immediately return to their reset state. The
RCM_SRS[WAKEUP] and RCM_SRS[PIN] bits are set and the system executes a reset
flow before CPU operation begins with a reset vector fetch."
So, as we thought, it reckons it should reset on wakeup, like it already does for the LLWU trigger pins that wake up the MCU.
Another curious detail that I've found, is that when I comment out the "LLWU_IRQHandler" I get the same behaviour with the watchdog timer when waking up from sleep due to an external pin waking up the MCU. This led me to think that this might be the area of the code that needs work done to.
My LLWU_IRQHandler now looks like:
void LLWU_IRQHandler(void)
{
//If wakeup by external pin.
if (LLWU_GetExternalWakeupPinFlag(LLWU, 6))//external pin
{
PORT_SetPinInterruptConfig(PORTC, 1, kPORT_InterruptOrDMADisabled);
PORT_ClearPinsInterruptFlags(PORTC, (1U << 1));
LLWU_ClearExternalWakeupPinFlag(LLWU, 6);
}
if (LLWU_GetExternalWakeupPinFlag(LLWU, 7))//external pin
{
PORT_SetPinInterruptConfig(PORTC, 1, kPORT_InterruptOrDMADisabled);
PORT_ClearPinsInterruptFlags(PORTC, (1U << 3));
LLWU_ClearExternalWakeupPinFlag(LLWU, 7);
}
if (LLWU_GetExternalWakeupPinFlag(LLWU, 10))//external pin
{
PORT_SetPinInterruptConfig(PORTC, 1, kPORT_InterruptOrDMADisabled);
PORT_ClearPinsInterruptFlags(PORTC, (1U << 6));
LLWU_ClearExternalWakeupPinFlag(LLWU, 10);
}
//new code
//try to get RTC LLWU Working
if(LLWU_GetInternalWakeupModuleFlag(LLWU, 5))//RTC alarm from page 264 of the reference manual
{
RTC_DisableInterrupts(RTC,kRTC_AlarmInterruptEnable );
RTC_ClearStatusFlags(RTC, RTC_SR_TAF_MASK);
RTC_StopTimer(RTC);
//RTC->TAR += 60; //add a minute as a test
}
}
As always, if anyone has any information that might be useful, it’s greatly appreciated.