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
CAN1 Instance Address: 0x40006400 CAN Error Code: 0x00020000
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