S32K3 How to change CAN bps online?

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

S32K3 How to change CAN bps online?

1,209 Views
EvaKi
Contributor I
 
0 Kudos
Reply
5 Replies

1,179 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @EvaKi,

You can change the FlexCAN bitrate through the configuration in peripherals: 

Julin_AragnM_0-1722538138012.png

Chapter 73.3.10.8.1 from the S32K3XX's Reference Manual explains the timing parameters required by the CAN protocol. You can also use the following community post for CAN bit timing calculation: MPC5xxx/S32Kxx/LPCxxxx: CAN / CAN FD bit timing calculation - NXP Community.

Best regards,
Julián

 

0 Kudos
Reply

1,158 Views
EvaKi
Contributor I

@Julián_AragónM Thanks for your response.

I know the method for changing CAN bps. For my issue is when I enable 500Kbps FlexCAN communication, I want to switch to 250Kbps. It was a failure. Even I re-init CAN driver.

That is what I say online. 

500Kbps work successfully, and switch to 250Kbps by a extra signal. It is failure

0 Kudos
Reply

1,111 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @EvaKi,

Chapter 73.6.2.3 Control 1 (CTRL1) from the Reference Manual specifies that these CAN bit timing variables can only be modified in freeze mode. They cannot be changed in runtime:

Julin_AragnM_0-1722890346555.png

Best regards,
Julián

0 Kudos
Reply

995 Views
EvaKi
Contributor I

@Julián_AragónM 

Sorry for taking so long to reply

 

For changing CAN bps, I use the FreezeMode. but it can be only effect on rise CAN bps.

such as: 250Kbps -> 500Kbps, it is ok.

250Kbps -> 125Kbps, it's not ok

 

void can_SetBitrate( uint8_t bitrate )
{
FlexCAN_Disable( IP_CAN_0 );
 
FlexCAN_Ip_EnterFreezeMode_Privileged(INST_FLEXCAN_0);
 
FlexCAN_Ip_SetBitrate_Privileged(INST_FLEXCAN_0,&can_pall_config[bitrate],FALSE);
 
FlexCAN_Ip_ExitFreezeMode_Privileged(INST_FLEXCAN_0);
 
FlexCAN_Enable( IP_CAN_0 );
}

 

0 Kudos
Reply

938 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @EvaKi

Could you share if any bus error appears while measuring CAN bus? Is this a problem while debugging or does the transceiver stop sending data? Please share what is meant by "not ok".

Are you using a CAN to USB analyzer? Or is this two CAN nodes?

Best regards,
Julián

0 Kudos
Reply