When I have the MX program set up CAN1 on my STM32F446 Nucleo-64 the generated code fails to initialize with the default values from MX.
it generates the following init using the default parameters:
static void MX_CAN1_Init(void)
{
/* USER CODE BEGIN CAN1_Init 0 */
/* USER CODE END CAN1_Init 0 */
/* USER CODE BEGIN CAN1_Init 1 */
/* USER CODE END CAN1_Init 1 */
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 16;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan1.Init.TimeSeg1 = CAN_BS1_1TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;
hcan1.Init.TimeTriggeredMode = DISABLE;
hcan1.Init.AutoBusOff = DISABLE;
hcan1.Init.AutoWakeUp = DISABLE;
hcan1.Init.AutoRetransmission = DISABLE;
hcan1.Init.ReceiveFifoLocked = DISABLE;
hcan1.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CAN1_Init 2 */
/* USER CODE END CAN1_Init 2 */
}And it falls immediately into the Error_Handler();
What do I need to do to fix it?
My second question is:
My system needs to have a CAN Baud rate of 1,000,000 because the other devices are running that speed. I cannot figure out how to make that happen. I tell it 1000000 for the baud rate and then I cannot figure out the Time Quanta in Bit Segment 1 or Bit Segment 2. Does this chip not support that speed? If not what will?
Thanks,
Kip