How to Set 5 Mbps Baud Rate for FlexCAN on KW45?

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

How to Set 5 Mbps Baud Rate for FlexCAN on KW45?

1,000 Views
jictannu
Contributor III

Hi,

I'm trying to configure a 5 Mbps baud rate for FlexCAN on a KW45 microcontroller. The available clock sources seem to be 48 MHz or 32 MHz, which don't allow for an exact 5 Mbps setting. Any suggestions on how to achieve this?

Thanks!

Labels (1)
Tags (1)
0 Kudos
Reply
5 Replies

984 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hello @jictannu

Hope you are doing well.

You could use flexcan demo application from KW45 SDK > driver_examples as a reference.

flexcan_config_t is the FlexCAN module configuration structure. You should be able to configure the bit rate by setting flexcan_config_t::bitRate (FlexCAN bit rate in bps, for classical CAN or CANFD nominal phase) and flexcan_config_t::bitRateFD (FlexCAN FD bit rate in bps, for CANFD data phase) data fields.

More information on this can be found in the MCUXpresso SDK API Reference Manual_KW45 included in KW45 SDK documentation folder > docs, Chapter 14 FlexCAN.

Regards,
Eduardo.

0 Kudos
Reply

979 Views
jictannu
Contributor III

Dear @EduardoZamora,

Thank you for your response.

I have tried setting the 'bitRateFD' to 5000000 as per your suggestion, but unfortunately, the communication fails at this setting. However, when I set the 'bitRateFD' to either 2000000 or 4000000, the communication works fine.

jictannu_0-1709774515451.png

 

I suspect that this issue arises due to the clock frequencies available for CAN on the KW45, which are 48 MHz and 32 MHz. These clock frequencies might not be able to generate an exact baud rate of 5 Mbps.

If you have any further suggestions or insights regarding this issue, I'd be very grateful.

Thank you for your time and assistance.

Best regards,

jictannu

0 Kudos
Reply

901 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

Please, refer to the KW45 Reference Manual, Chapter 50 CAN (FlexCAN), Section 50.3.12.1 Clock domains and restrictions for more information on this.

Regards,
Eduardo.

0 Kudos
Reply

897 Views
jictannu
Contributor III

 

Dear @EduardoZamora 

Thank you for pointing me toward the reference material. I have reviewed Chapter 50 of the KW45 Reference Manual, specifically Section 50.3.12.1 regarding clock domains and restrictions. Despite this, I'm still unclear about the proper configuration to achieve a 5 Mbps baud rate with the given clock sources.

Would it be possible for you to provide me with a sample configuration code that sets up the FlexCAN for a 5 Mbps baud rate? It would be immensely helpful to see a working example.

I appreciate your help and patience.

Best regards,

jictannu

0 Kudos
Reply

835 Views
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

You could take a look at the flexcan_config_t configuration structure from fsl_flexcan.h file. This structure has a member flexcan_timing_config_t timingConfig which could help you with the protocol timing characteristics to try to meet your requirements, together with the KW45 Reference Manual, Section 50.3.11.7 Protocol timing.

Regards,
Eduardo.

0 Kudos
Reply