Dear NXP-expert
current environment description:
Package: S32 Design Studio Platform package; Version: 3.4.3; Build id: 202112151555
Package: FreeRTOS for S32K3 2.0.0; Version: 2.0.0; Build id: 202204280242
Package: S32K3xx development package; Version: 3.4.3; Build id: 202112162057
Package: S32K3 RTD AUTOSAR 4.4 Version 2.0.0; Version: 2.0.0; Build id: 202203311410
I would like to enable S32K312NHT0MPBSR's CAN bus by example FlexCAN_Ip_Example_S32K312.
I had config it to FLEXCAN_5 and init it
I can not saw any wave when i send a CAN message
Are there any wrong config at following initial and send command?
#define Rx_MSG_ID 0x08u
#define Tx_MSG_ID 0x16u
#define RX_MB_IDX 1U
#define TX_MB_IDX 0U
FlexCAN_Ip_Init(INST_FLEXCAN_5, &FlexCAN_State5, &FlexCAN_Config5);
FlexCAN_Ip_SetRxMaskType(INST_FLEXCAN_5,FLEXCAN_RX_MASK_INDIVIDUAL);
FlexCAN_Ip_SetRxIndividualMask(INST_FLEXCAN_5,RX_MB_IDX,0);
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_5, RX_MB_IDX, &rx_info, Rx_MSG_ID);
FlexCAN_Ip_SetStartMode(INST_FLEXCAN_5);
FlexCAN_Ip_Send(INST_FLEXCAN_5, TX_MB_IDX, &rx_info, Tx_MSG_ID, (uint8 *)&dummyData);
and
BR
Daniel
已解决! 转到解答。
Hi @DanielYJHsieh,
S32K312EVB uses a different transceiver than TJA1044. In your case, CAN_STB must be LOW for normal mode. From TJA1044's data sheet:
I can receiver 0x55 and 0xFACE ID CAN BUS.
How to config for more IDs
These lines configure the received IDs:
rx_info.msg_id_type = FLEXCAN_MSG_ID_EXT;
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_0, RX_MB_IDX, &rx_info, 0xFACE); //MB = 1 : ID : 0xFACE : Extended ID
rx_info.msg_id_type = FLEXCAN_MSG_ID_STD;
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_0, RX_MB_IDX_0, &rx_info, 0x55); // MB = 0 : ID = 0x55 : STANDARD ID
You can add more IDs to be received or set the acceptance mask to 0x0 to receive all IDs.
There is a community post explaining how to use the mask settings: S32K1xx-FlexCAN Mask Setting Demo - NXP Community. It is based on the S32K1 devices, but the same principles apply.
Dear Julián
I had porting the S32K312_CAN_TX_RX_using_MB_Interrupt_working.zip of Example S32K312 CAN Transmit & Receive Using MB Interrupt DS3.5 RTD300 - NXP Community to my platform.
I use INST_FLEXCAN_5 other LED,
Which part need to be change too?
How about following function?
/*Initial ISR*/
Should i change to
IntCtrl_Ip_EnableIrq(FlexCAN5_0_IRQn);
IntCtrl_Ip_EnableIrq(FlexCAN5_1_IRQn);
How to testing it.
What should the Prop Seg/Seg 1/Seg 2/Pre Divider/Resync jump width of FlexCAN_Config0 be?
What does the PCAN VIIEW config should be?
Thank you very much
Yes, if you are using FlexCAN5, simply change the configuration for instance 5.
You can use this spreadsheet calculator for CAN bit timing segments: MPC5xxx/S32Kxx/LPCxxxx: CAN / CAN FD bit timing calculation - NXP Community.
For testing purposes, match the same configuration in PCAN View and in MCU, for example:
S32K3 with 500Kbps & SP 87.5%:
PEAK View w/same config:
Bus status should be OK:
Best regards,
Julián
Dear Julián
Sofar, i can send out the CAN Tx Message and Tx Message
I need to mark //Siul2_Dio_Ip_WritePin(PTC_L_HALF, 6u, 1U); //CAN5_STB
Why example set high STB pin?
Hi @DanielYJHsieh,
S32K312EVB uses a different transceiver than TJA1044. In your case, CAN_STB must be LOW for normal mode. From TJA1044's data sheet:
I can receiver 0x55 and 0xFACE ID CAN BUS.
How to config for more IDs
These lines configure the received IDs:
rx_info.msg_id_type = FLEXCAN_MSG_ID_EXT;
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_0, RX_MB_IDX, &rx_info, 0xFACE); //MB = 1 : ID : 0xFACE : Extended ID
rx_info.msg_id_type = FLEXCAN_MSG_ID_STD;
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_0, RX_MB_IDX_0, &rx_info, 0x55); // MB = 0 : ID = 0x55 : STANDARD ID
You can add more IDs to be received or set the acceptance mask to 0x0 to receive all IDs.
There is a community post explaining how to use the mask settings: S32K1xx-FlexCAN Mask Setting Demo - NXP Community. It is based on the S32K1 devices, but the same principles apply.
Dear @Julián_AragónM
I had double check the scope.
The rate is 500K as picture.
Any thing i need to check more?
PC Tool PCAN-view's waveform
Device side's waveform
The H-L math waveform
Dear @Julián_AragónM
Could you please help to check following config is correct or not?
Me device's CAN become NG, however i did not change the config
The scope have waveform ,but the PCAN-view can not receiver message.
I suspect the device did not send the correct
Dear Julián
My SW version is
Package: S32 Design Studio Platform package; Version: 3.4.3; Build id: 202112151555
Package: FreeRTOS for S32K3 2.0.0; Version: 2.0.0; Build id: 202204280242
Package: S32K3xx development package; Version: 3.4.3; Build id: 202112162057
Package: S32K3 RTD AUTOSAR 4.4 Version 2.0.0; Version: 2.0.0; Build id: 202203311410
I use my own board, design as following
i do following config to use CAN5.
Please help to review the steps
MCU: S32K312
CAN Module: FlexCAN5
Clock: FLEXCAN5_CLK = 24MHz
Pins: PTC26 (RX), PTC27 (TX)
Bit Rate: 500 kbps
Hi @DanielYJHsieh,
Your basic configuration seems ok. Are you using an S32K312-EVB? Or is this a custom design? Please confirm if the pinout and CAN bus design is correct. You can base the design from the EVB (using a TJA1153 transceiver):
Also, I assume you are also configuring and initializing the clocks and pins correctly. You can use these community posts as reference:
Best regards,
Julián