Skip to main content
Evan .1
Associate III
April 22, 2020
Question

STM32F7 CAN exit Sleep mode

  • April 22, 2020
  • 2 replies
  • 1237 views

I'm making my own low level CAN driver.

I have a problem releasing the CANperipheral from sleep mode.

So there are more requirements then I found so far.

			LL_AHB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_CAN1);
			LL_AHB3_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_CAN1);
			LL_AHB3_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_CAN1);
			/* Exit from sleep mode */
			CLEAR_BIT(Instance->MCR, CAN_MCR_SLEEP);
			while ((Instance->MSR & CAN_MSR_SLAK) != 0U);

Any suggestion?

Thanks!

This topic has been closed for replies.

2 replies

TDK
April 22, 2020

You're mixing up AHB1, APB1, and AHB3. You need to call the correct one, with the correct argument. The LL file lists the valid arguments for each call.

LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_CAN1);
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_CAN1);
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_CAN1);

"If you feel a post has answered your question, please click ""Accept as Solution""."
Evan .1
Evan .1Author
Associate III
April 22, 2020

Ok thanks. That did not solve it unfortunately.

Evan .1
Evan .1Author
Associate III
April 28, 2020

Somehow the candriver I/O needs to be configured before the module can exit sleep mode.

I can't get the io pins configured correctly with the lowlevel driver

So what is the difference between this two:

   __HAL_RCC_GPIOA_CLK_ENABLE();

 GPIO_InitStruct.Pin = GPIO_PIN_12;

 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

 GPIO_InitStruct.Pull = GPIO_PULLUP;

 GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /* CAN1 RX GPIO pin configuration */

 GPIO_InitStruct.Pin = GPIO_PIN_11;

 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

 GPIO_InitStruct.Pull = GPIO_PULLUP;

 GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

and:

 __HAL_RCC_GPIOA_CLK_ENABLE();

   LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);

   LL_GPIO_SetPinSpeed(GPIOA, LL_GPIO_PIN_12, LL_GPIO_SPEED_FREQ_VERY_HIGH);

   LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_12, LL_GPIO_OUTPUT_PUSHPULL);

   LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_12, LL_GPIO_PULL_UP);

   LL_GPIO_SetAFPin_8_15(GPIOA, LL_GPIO_PIN_12, LL_GPIO_AF_9);

   LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_12, LL_GPIO_MODE_ALTERNATE);

   LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);

   LL_GPIO_SetPinSpeed(GPIOA, LL_GPIO_PIN_11, LL_GPIO_SPEED_FREQ_VERY_HIGH);

   LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_11, LL_GPIO_OUTPUT_PUSHPULL);

   LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_11, LL_GPIO_PULL_UP);

   LL_GPIO_SetAFPin_8_15(GPIOA, LL_GPIO_PIN_11, LL_GPIO_AF_9);

   LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_11, LL_GPIO_MODE_ALTERNATE);

Edit: solved.