Showing results for 
Search instead for 
Did you mean: 

STM32F098 CAN works in loopback mode but not in normal mode

Associate II

Hello, for my personnal project I use a stm32F98 with the CAN peripheral activated.

First of all I have an issue with the configuraiton gave in the stm32f0_firmware example but if I set the GPIO_InitStruct.Pull to GPIO_NOPULL, I cannot have the INAK bit reset when going from initialization mode to Normal mode.

The solution to have it reset was to set GPIO_InitStruct.Pull to PullUp.

But then I had another issue : The peripheral do not receive/transmit any message.

When configured in LoopBack mode, it receives what it has just transmitted, so I assume that I have configured it well.

I've followed stm32f0_firmware example to configure bit timing and I have a 120ohm termination resistor right after the transceiver.

At this stage I really don't know what could cause this behaviour and I'm pretty lost..


In loop-back mode the speed settings are going to match, and you don't need a responding device on the bus.

No real data here to validate speed, clock, settings, or anything.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I'm using a CAN232 dongle ( ) to read/write message on the bus from the ocmputer. I've configured the dongle speed to 1Mbit/s.

My STM32f0 settings are :

 /* USER CODE END CAN_Init 1 */

 hcan.Instance = CAN;

 hcan.Init.Prescaler = 4;

 hcan.Init.Mode = CAN_MODE_NORMAL;

 hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;

 hcan.Init.TimeSeg1 = CAN_BS1_5TQ;

 hcan.Init.TimeSeg2 = CAN_BS2_6TQ;

 hcan.Init.TimeTriggeredMode = DISABLE;

 hcan.Init.AutoBusOff = DISABLE;

 hcan.Init.AutoWakeUp = DISABLE;

 hcan.Init.AutoRetransmission = DISABLE;

 hcan.Init.ReceiveFifoLocked = DISABLE;

 hcan.Init.TransmitFifoPriority = DISABLE;

 if (HAL_CAN_Init(&hcan) != HAL_OK)




GPIO settings :

 GPIO_InitTypeDef GPIO_InitStruct = {0};



 /* USER CODE BEGIN CAN_MspInit 0 */

 /* USER CODE END CAN_MspInit 0 */

  /* CAN clock enable */



  /**CAN GPIO Configuration

  PA11   ------> CAN_RX

  PA12   ------> CAN_TX


  GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;



  GPIO_InitStruct.Alternate = GPIO_AF4_CAN;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);


/* CAN interrupt Init */

HAL_NVIC_SetPriority(CEC_CAN_IRQn, 2, 0);


 /* USER CODE BEGIN CAN_MspInit 1 */

By the way I've tried to catch frames with an oscilloscope but nothing comes out of the MCU.. Even if the timing was not good, I should see frames coming out of the TX pin don't I?