Skip to main content
Christian Neubert
Associate II
March 5, 2018
Solved

STM32L496ZG Nucleo-144 CAN initialization

  • March 5, 2018
  • 1 reply
  • 805 views
Posted on March 05, 2018 at 15:19

I have Nucleo-144 Board with a STM32L496ZG and use it for evaluation if the MCU will work for us. But I´m stuck with the CAN initialization.

I have the following init code:

// CAN clock
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_CAN1);
// CAN Tx
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD);
LL_GPIO_SetAFPin_8_15(GPIOD, LL_GPIO_PIN_1, LL_GPIO_AF_9);
LL_GPIO_SetPinPull(GPIOD, LL_GPIO_PIN_1, LL_GPIO_PULL_UP);
LL_GPIO_SetPinOutputType(GPIOD, LL_GPIO_PIN_1, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinMode(GPIOD, LL_GPIO_PIN_1, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinSpeed(GPIOD, LL_GPIO_PIN_1, LL_GPIO_SPEED_FREQ_VERY_HIGH);
// CAN Rx
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD);
LL_GPIO_SetAFPin_8_15(GPIOD, LL_GPIO_PIN_0, LL_GPIO_AF_9);
LL_GPIO_SetPinPull(GPIOD, LL_GPIO_PIN_0, LL_GPIO_PULL_UP);
LL_GPIO_SetPinOutputType(GPIOD, LL_GPIO_PIN_0, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinMode(GPIOD, LL_GPIO_PIN_0, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinSpeed(GPIOD, LL_GPIO_PIN_0, LL_GPIO_SPEED_FREQ_VERY_HIGH);�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

If I debug this code and execute the line 'LL_GPIO_SetPinMode(GPIOD, LL_GPIO_PIN_1, LL_GPIO_MODE_ALTERNATE);', the TX and RX pin go to 0V and even when I executed all of the above code they stay there.

If I then want to get the CAN controller out of sleep mode it does not work, because the CAN controller waits for some high bits on the RX pin and will never see them.

Is there a really stupid mistake I´m making? Did someone else get the CAN controller running without using the HAL?

#can-examples #stm32-l4 #can-programming
This topic has been closed for replies.
Best answer by Christian Neubert
Posted on March 05, 2018 at 16:06

Ok, there is a really really stupid mistake.

I need to call 'LL_GPIO_SetAFPin_0_7' and not 'LL_GPIO_SetAFPin_8_15'

1 reply

Christian Neubert
Christian NeubertAuthorBest answer
Associate II
March 5, 2018
Posted on March 05, 2018 at 16:06

Ok, there is a really really stupid mistake.

I need to call 'LL_GPIO_SetAFPin_0_7' and not 'LL_GPIO_SetAFPin_8_15'