cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32f446re CAN start error

Yakry
Associate II

 

CAN Bus Not Starting - HAL_CAN_Start() Error (0x00020000)

Post:

I'm facing an issue where my CAN bus does not start. Tera Term shows the following messages:

 

less
CopyEdit
CAN1 Instance Address: 0x40006400 CAN Error Code: 0x00020000
 
CopyEdit
HAL_Init(); 
/* USER CODE BEGIN Init */ 
/* USER CODE END Init */ 
/* Configure the system clock */ 
SystemClock_Config(); 
/* USER CODE BEGIN SysInit */ 
/* USER CODE END SysInit */ 
/* Initialize all configured peripherals */ 
MX_GPIO_Init(); 
MX_CAN1_Init(); 
MX_TIM6_Init(); 
MX_USART2_UART_Init(); 
/* USER CODE BEGIN 2 */ 
filter_config(); 
HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING); 
sprintf(msg, "CAN1 Instance Address: 0x%08lX\n", (uint32_t)hcan1.Instance); 
HAL_UART_Transmit(&huart2, (uint8_t *)msg, strlen(msg), HAL_MAX_DELAY); 
if (HAL_CAN_Start(&hcan1) != HAL_OK) 
{ 
  sprintf(msg, "CAN Error Code: 0x%08lX\n", HAL_CAN_GetError(&hcan1)); 
  if (HAL_UART_Transmit(&huart2, (uint8_t *)msg, strlen(msg), HAL_MAX_DELAY) != HAL_OK) 
  {
    Error_Handler(); 
  } 
  Error_Handler(); 
}

 

I have already checked the following:
:heavy_check_mark:CAN1 initialization (MX_CAN1_Init())
:heavy_check_mark:Notifications (HAL_CAN_ActivateNotification)
:heavy_check_mark:Debugging in STM32CubeIDE

 

1 REPLY 1
mƎALLEm
ST Employee

Hello,

Are you familiar with the CAN protocol? if not CAN is not SPI or UART to use it in standalone (only one node) in Normal mode.

So what is your CAN configuration: Loopback or Normal mode?

If Normal mode, are you establishing a complete CAN bus by using transceivers? Refer to this figure.

Also, to help you efficiently you need to provide the schematics including the transceivers + your complete project including the ioc file.

Did you try the Loopback mode? what did you find? see also this article if it's the case.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.