Skip to main content
J75888.1
Associate II
May 12, 2021
Solved

How to come out from sleep mode using CAN interrupt?

  • May 12, 2021
  • 2 replies
  • 867 views

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.

This topic has been closed for replies.
Best answer by DOCon.1

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)

2 replies

DOCon.1
DOCon.1Best answer
Senior
May 12, 2021

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
J75888.1Author
Associate II
May 13, 2021

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