Is it possible to change the CAN baud rate on the fly?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is it possible to change the CAN baud rate on the fly?

1,863 Views
mpfgregory
Contributor III

Hello all,

I'm developing a product based on a Vybrid Vf6. I'm running MQX on the M4 core. The HMI on the A5 allows the user to change the baud rate for CAN0 and CAN1. Both CAN ports are controlled by the fsl_flexcan_driver on the M4. For testing purposes I connect the 2 CAN ports and have them send messages to each other. This works fine at all baud rates, but only if I set both to equal baud rates before establishing a physical connection. The following scenarios will crash the CAN driver:

1) The 2 ports are not physically connected. Set the 2 baud rates to different values, then establish the physical connection.

2) The 2 ports are physically connected and run on the same baud rate. Change the baud rate of one port while the connection is present.

In both cases the driver doesn't work anymore. There is no crash in the software, but when I measure the signal on the CAN bus with an oscilloscope, there is only silence. Disconnecting the 2 ports, setting their baud rate to the same value, then reconnecting them doesn't help either. Only after a reboot of the M4 the CAN ports are working again.

Has anybody seen this problem? Is it related to the driver, or is this usual behavior for CAN devices? Would the customers accept this restriction?

Best regards

Michael

0 Kudos
2 Replies

1,429 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Michael:

This is not a common scenario.

If you want to change baud rate, I think you need to halt (enter freeze).  I recommend do a FLEXCAN module software reset and then perform a full re-initialization.

Regards

Daniel

1,429 Views
mpfgregory
Contributor III

Hello Daniel,

I've tried to use freeze and unfreeze around the baud rate change, but this doesn't help. If this was necessary, I would expect the driver to do this automatically. Resetting the complete FLEXCAN module helps! The fsl_flexcan_driver is not robust enough for the baud rate change. It relies on a lw_event for send and receive, which is set by the ISR. So when I change the baud rate while the driver waits for the event, it gets stuck. flexcan_shutdown() kills the lw_event and releases the driver from the _lwevent_wait_ticks().

It's not working 100% reliably yet, but if it gets stuck it can already be fixed by simply switching the baud rate again.

Thanks for your help!

0 Kudos