S32K1xx Interrupt Wake-up from other location than main.c

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K1xx Interrupt Wake-up from other location than main.c

Jump to solution
1,016 Views
ndousse
Contributor II

Hello,

I am trying to implement a sleep wake-up procedure on the S32K146 development board. 

To send the controller to sleep, I use the code from the Application notes AN5425, chapter 5.5.1. 

S32_SCB->SCR |= S32_SCB_SCR_SLEEPDEEP(1);
/* Select Stop Mode */
SMC->PMCTRL = SMC_PMCTRL_STOPM(0b00);
/* Select which STOP mode (Stop1 or Stop2)
 * is desired (Stop1 - 0b01, Stop2 - 0b10) */
SMC->STOPCTRL = SMC_STOPCTRL_STOPO(0b01);
/* Wait For Interrupt */
#if defined (__GNUC__)
__asm volatile ("wfi");
#endif

The go to sleep procedure works without any issue, no matter the stop mode that I use. 

To wake-up the controller, I want to trigger a LIN interruption using the LIN 2.1 stack from the NXP SDK. LIN communication is working properly. 

 

Issue that I am facing:

  • If the command "__asm volatile ("wfi");" is called from the file "main.c", the wake-up procedure through LIN (or a pin interruption based on a button pressed on the development board) works without any issue.
  • However, if I moved this command to another file, I cannot trigger any interruption to wake-up the controller (neither a LIN interruption nor a Pin based interruption based on the button of the development board). 
  • I also tried to use the NXP SDK power manager module generated from the Processor Expert and face exactly the same issue. 

My question:

What do I need to define or modify in order to be able to wake-up the controller from any file?

Thank you for your guidance.

0 Kudos
1 Solution
985 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @ndousse,

The MCU starts running in the wakeup ISR, and once the ISR is complete, it returns to the next inxtruction after WFI.

So, if the AWIC does not detect the interrupt, please make sure that when the WFI is executed

  • the interrupts are not masked
  • the WFI is not in an ISR that cannot be preempted (higher priority).

 

Regards,

Daniel

View solution in original post

0 Kudos
4 Replies
971 Views
ndousse
Contributor II

Dear Daniel,

Thank you for your answer. 

The "__asm volatile ("wfi");" is indeed called from an interrupt, a scheduler based on a lptmr interrupt. The LPTMR_DRV_ClearCompareFlag is cleared directly at the beginning of the interrupt, before the call to the "wfi". 

No interrupt mask is applied. 

All the interruption have their default priority. Following the S32K1xx_DMA_Interrupt_mapping.xlsx, the LPUART interrupts have a lower Interrupt ID (ID 31-35) than the LPTMR interrupt ID (ID 58). So the LPUART should have a higher priority than the LPTMR, is it correct?

Can I simply change the priority of the LPTMR interrupt to a lower one in order to trigger the LPUART interrupt as AWIC?

0 Kudos
967 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @ndousse,

If all the interrupts have thier priority set to 0 (default), one interrupt can't preempt the other.

You would need to set the LPTMR interrupt to a lower periority (like 1).

 

BR, Daniel

0 Kudos
956 Views
ndousse
Contributor II

Dear Daniel,

I setup the priority of the LPTMR interruption to 1 with the function

 

INT_SYS_SetPriority(LPTMR0_IRQn, 1);

 

And I was able to trigger the LIN interruption through LPUART. 

Thanks for your guidance and help.

986 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @ndousse,

The MCU starts running in the wakeup ISR, and once the ISR is complete, it returns to the next inxtruction after WFI.

So, if the AWIC does not detect the interrupt, please make sure that when the WFI is executed

  • the interrupts are not masked
  • the WFI is not in an ISR that cannot be preempted (higher priority).

 

Regards,

Daniel

0 Kudos