cancel
Showing results for 
Search instead for 
Did you mean: 

How to come out from sleep mode using CAN interrupt?

J75888.1
Associate II

Hello All,

I am using sleep mode to save power. I am using STM32L431RC & using CAN interface.

I am able to enter into the sleep mode when a CAN message is received.

But it doesn't come out when a CAN interrupt is received.

My code for CAN interrupt handler

 HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &pHeaderRx, DataRx);

if(pHeaderRx.ExtId == 0x056E0410)

 {

   if(DataRx[0] == 0xD0)

     {

    HAL_PWR_DisableSleepOnExit ();

    HAL_ResumeTick();

     }

   else if(DataRx[0] == 0xD1)

     {

      HAL_SuspendTick();

    HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);

     }

else

     {};

}

Any help will be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
DOCon.1
Senior

Hi! Make sure you doing the following:

  • Unmask the appropriate CAN interrupt in the cortex-M NVIC
  • Enable the appropriate CAN interrupt in the CAN register block (maybe CAN_CR?)
  • Set up an interrupt handler funtion for this CAN interrupt, where you clear the interrupt flat (maybe CAN_ICR)

View solution in original post

2 REPLIES 2
DOCon.1
Senior

Hi! Make sure you doing the following:

  • Unmask the appropriate CAN interrupt in the cortex-M NVIC
  • Enable the appropriate CAN interrupt in the CAN register block (maybe CAN_CR?)
  • Set up an interrupt handler funtion for this CAN interrupt, where you clear the interrupt flat (maybe CAN_ICR)
J75888.1
Associate II

Thank you DOCon.1 for your reply.

I m using cubeMax for pin configuration and atollic trueStudio for development.

It is entering in sleep mode successfully but not coming out from sleep mode when next expected CAN data is received. as shown in above code.

Kindly find image of NVIC setting.0693W00000AOCuEQAX.jpg