AnsweredAssumed Answered

STM32L496ZG Nucleo-144 CAN initialization

Question asked by Christian Neubert on Mar 5, 2018
Latest reply on Mar 5, 2018 by Christian Neubert

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?

Outcomes