2021-01-21 03:41 AM
I have configured CAN module 1 on the STM32F412 and it works fine when initialized with a certain BAUD rate (For example 500K). I have a GPIO input, which when toggled needs to changed the BAUD rate to 250K. The sequence I am following with STM32Cube_FW_F4_V1.25.2 functions is as follows:
HAL_CAN_DeInit(&hcan1); // Also calls the HAL_CAN_Stop function
hcan1.Init.Prescaler = CAN_BAUD_250K; // change the BAUD
if(HAL_CAN_Init(&hcan1) != 0) // Re-init
{
printf("CAN not initialized!\r\n");
}
if(HAL_CAN_Start(&hcan1) != 0) // Start
{
printf("CAN not started!\r\n");
}
I expect the CAN module to re-init with the changed BAUD rate and start recv/trans messages although The HAL_CAN_Start function times out as it cannot receive an ACK on the CAN_MSR_INAK after 10 ms.
In the MSP init config I have pulled up the CAN_RX/TX GPIOs. At first glance this does not seem like a hardware issue to me as the CAN module works as expected during first initialization - but just not after changing the prescaler and re-initializing. I also tried re-initializing the filter before I start the module but I just cannot get an ACK with the CAN_MSR_INAK bit and it times out.
Any ideas to debug this further will be highly appreciated.
Thanks,
KD