cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L45Q CAN Bus will not leave sleep, Initialization, or reset

DPlum
Associate II
 
2 REPLIES 2
DPlum
Associate II

I am trying to bring up a new board and am running into a problem initializing the CAN bus.

Part: STM32L4Q5CGT6P

CAN baud rate 500kbps

Can Transceiver is being used.

I first found this problem with custom code but it is probably easier to describe relating to cube / Hal code that has the same results.

Using the standard Cube/Hal code for this part the first sign of a problem is that it fails on CAN_init

The following code will always hit the error handler

   CanHandle.Instance = CANx;

   CanHandle.Init.TimeTriggeredMode = DISABLE;

   CanHandle.Init.AutoBusOff = DISABLE;

   CanHandle.Init.AutoWakeUp = DISABLE;

   CanHandle.Init.AutoRetransmission = ENABLE;

   CanHandle.Init.ReceiveFifoLocked = DISABLE;

   CanHandle.Init.TransmitFifoPriority = DISABLE;

   CanHandle.Init.Mode = CAN_MODE_NORMAL;

   CanHandle.Init.SyncJumpWidth = CAN_SJW_1TQ;

   CanHandle.Init.TimeSeg1 = CAN_BS1_5TQ;

   CanHandle.Init.TimeSeg2 = CAN_BS2_2TQ;

   CanHandle.Init.Prescaler = 15;

   if (HAL_CAN_Init(&CanHandle) != HAL_OK)

   {

      /* Initialization Error */

      Error_Handler();

   }

   Monitoring the registers involved I have noticed the following.

   MSR->Reset never clears the reset bit

   Using cube code it will not leave sleep

   If I clear sleep in MCR and Set INRQ I can get it to move from sleep to Initializing (MSR->INAK) but it will never leave INAK.

   To eliminate problems I removed the CAN transceiver and installed a 3.3k pull up to 3.3v with a diode to tx joining the RX and TX pins together. This had no effect on the problems above.

   I have also tried the "Can_Networking" example from Cube L4 ported over to this part and still receive the same errors.

   Has anyone seen this before? I am hoping there is some register or peripheral power I am missing somewhere in the process.

DPlum
Associate II

After further testing I have found that the issue is related to the use of alternate pins PB8 and PB9 if I move the CAN interface to PA11 and PA12 it works as documented. Do you know why I cannot move CAN to pins PB8 and PB9 as documented in the datasheet? Is there another clock that needs to be enabled in this situation other then GPIOB_CLK?

I am still using AF_9 alternate functions but CAN never leaves reset when pins are on PB8 and PB9.

I cannot permanently move to AF11 and AF12 as I can only use these pins for USB. The only alternate for CAN1 is PB8 and PB9 that do not work.