how to use MBDT to initialize the TJA1153 CAN on MRCANHUBK344

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

how to use MBDT to initialize the TJA1153 CAN on MRCANHUBK344

Jump to solution
1,023 Views
HarryQi
Contributor III

Dear NXP 

I am using MRCANHUBK344 evaluation board to develop CAN application with MBDT toolbox and S32 configuration tools , now i can successfully use FLexCAN0~FlexCan3 to transmit and receive msgs,but 

i can't use FlexCAN4 and FlexCAN5 which are TJA1153A aka secure CAN Transceiver, Please give me some advice and help。

Thanks !

Harry Qiimage-20240108174954019.png

0 Kudos
1 Solution
869 Views
HarryQi
Contributor III

Hello, @robertv  ,

Thank you so much!  what a great help you have given!

   Yes, I tried the model you attached, it works now, i can successfully use Flexcan4 and Flexcan5 to transmit messages!

   Forgive me for asking more questions. I want to use  Flexcan0 to transmit  three msgs like ID 0x01 ,0x02 , 0x03 and to receive msgs like ID 0x04, 0x05,0x06 , to achieve this purpose, what should i do with the configurations  and the simulink model?

BR!

HarryQi

View solution in original post

0 Kudos
11 Replies
1,003 Views
robertv
NXP Employee
NXP Employee

Hello @HarryQi ,

Since the TJA1153 is a secure CAN Transceiver, its initialization process is different from the other 2 types present on the board.

For reference, you could open the s32k3xx_can_transmit_ebt.mdl example from the S32K3_Examples/can folder and take a look at the initialization sequence for TJA1153.

You can also copy the TJA1153_Init MATLAB Function and paste it in into your model, instead of the DIO blocks used to control the STB and EN pins.

robertv_0-1704791685377.png

First of all, the inputs to the MATLAB Function are as follows:
- canExtHwId - represents the ID of the polling transmit hardware object set in the CanConfigSet->CanHardwareObject section of the configuration tool
- canEnDioChannel - represents the CAN_EN pin's MSCR as hex
- canStbDioChannel - represents the CAN_STB pin's MSCR as hex
- canErrnDioChannel - represents the CAN_ERRN pin's MSCR as hex

robertv_1-1704792901747.png

Afterwards, there's one more thing you should keep in mind. For the transceiver to work properly, a power cycle is required in the current version, meaning that after the code is uploaded on the board, the board's power supply should be disconnected and then reconnected. This should also be done after the reset button has been pressed, to allow the transceiver to switch to a normal working state.


Regards, 
Robert V

972 Views
HarryQi
Contributor III

FLEXcan4-5.pngTJA1153INI.pngHello, @robertv ,

Thank you so much for your reply!

I did what you said ,but i still can't make it work ,i attach my initialization screenshot here,and .mex file ,could you help me  check whether it is right ! Thanks again !

 

0 Kudos
949 Views
robertv
NXP Employee
NXP Employee

Hello @HarryQi ,

After taking a look at the attached model, there is one thing that stood out to me as a possible problem.

For the blocks to function properly, they also require the Can_SetControllerMode block with the mode set to CAN_CS_STARTED. This should be done for both of the CanControllers 4 and 5, as seen below.

robertv_0-1705313160709.png

Could you try to add these blocks and, along with the mentions regarding the power on-off cycle, check whether the problem is gone?
Please let me know if this has fixed your issue.


Regards, 
RobertV

0 Kudos
932 Views
HarryQi
Contributor III

Hello, @robertv  ,

 Thank you for support!  unfortunately,after adding the can4 and can5  "Can_SetControllerMode"  which is selected to "CAN_CS_STARTED",  and after power on-off cycle ,it still doesn't  fix the problem with CAN4 and CAN5. 

if you test the model on your EVB and it works well, It would be so kind of you, if you can share the working-version model and setting-files with me .

BR

HarryQi

0 Kudos
903 Views
robertv
NXP Employee
NXP Employee

Hello @HarryQi ,

Based on the model you have attached here, I added the Can_SetControllerMode set to CAN_CS_STARTED, as mentioned in the previous reply.

Additionally, inside the configuration, I set the Initial Value for  LED_CAN4 and LED_CAN5 to HIGH so they are turned off by default. I have also set the Message ID for Can4 to "4" and for Can5 to "5" so they are easily identifiable on the CAN Bus.

robertv_0-1705399675991.png

After building and downloading the model to the board, LED_CAN4 and LED_CAN5 are turned ON. I disconnect the board's power supply and then reconnect it. At this point, all the CAN LEDs are OFF and the CAN messages can be seen when checking the Can Analyzer connected to the CAN Bus (only connected to CAN4 and CAN5):

robertv_2-1705399940500.png

I have also attached the .bin and .elf files, so you can test another scenario by downloading them directly to the board using the mbd_s32k3.nxp.download.jlink('./mrcanhubk344_can_s32ct.bin') command, ran in MATLAB, in the same folder as the .bin file.

Note: a board reset using the reset button is not a substitute for the power cycle, and it should be done after every reset/code upload when using the TJA1153 transceiver and the current version. Also, all the CAN ports should be populated for instances that are supposed to be communicating. On my board I have the following connections:

robertv_3-1705401321386.png

If after these steps the issue still exists, do not hesitate to reach out again.

Regards,
Robert V

0 Kudos
870 Views
HarryQi
Contributor III

Hello, @robertv  ,

Thank you so much!  what a great help you have given!

   Yes, I tried the model you attached, it works now, i can successfully use Flexcan4 and Flexcan5 to transmit messages!

   Forgive me for asking more questions. I want to use  Flexcan0 to transmit  three msgs like ID 0x01 ,0x02 , 0x03 and to receive msgs like ID 0x04, 0x05,0x06 , to achieve this purpose, what should i do with the configurations  and the simulink model?

BR!

HarryQi

0 Kudos
848 Views
robertv
NXP Employee
NXP Employee

Hello @HarryQi ,

I am glad to hear that the model is now working properly for you.

If you want to send three different CAN messages from the same instance, on the same execution step, the solution involves using 3 Can Write blocks and configuring the CAN hardware object to support 3 items.

robertv_0-1705500807146.png

robertv_1-1705500844041.png

As for receiving specific messages, I hope I am not misunderstanding your request, but if you want to filter messages and only receive messages corresponding to specific IDs, you could use the filters described in the chapter 2.3.2. from the article about using MR-CANHUBK344 to communicate with CAN https://community.nxp.com/t5/NXP-Model-Based-Design-Tools/Communicating-over-the-CAN-Bus/ta-p/175845... .

Regards,
Robert V

 

0 Kudos
834 Views
HarryQi
Contributor III

Hello, @robertv ,

 Thank you for your support!  As for the questions about using one CAN instance for receiving messages, i should  have said it more clearly. 

For example, i hope to use Flexcan1 to receive messages with ID 0X05, 0X06 and 0X07 respectively , do i need to  add  three "CanIf_ RxIndication" modules  in the model ?  how can i  tell  what the received message's ID is ?

BR!

HarryQi

0 Kudos
806 Views
robertv
NXP Employee
NXP Employee

Hello @HarryQi ,

Using the CanIf_RxIndication interrupt block you can process the messages that are received by the CAN instances. The block has a few outputs that can help you identify which instance/controller received the message and what the message's content is.

robertv_0-1705596648761.pngFor example, if you want the CAN2 to process the messages with IDs 0x05, 0x06, 0x07, you could process them based on the ControllerID that the block returns and the ID of the message.

One more thing you should pay attention to. In the configuration used by your project, the RECEIVE objects are set to POLLING and in order to receive CAN messages, an additional block has to be used:

robertv_2-1705597455606.png

The alternative would be to configure RECEIVE hardware objects that use interrupts instead of polling, which would work without the need for the Can_MainFunction_Read block.

To simplify the process, you could store these in Data Store Memory variables and shown in FreeMASTER.

robertv_1-1705597195332.png

Note: the variables must be configured as "Volatile". More details about how to achieve that can be found in the chapter 5 of the article https://community.nxp.com/t5/NXP-Model-Based-Design-Tools/Sending-data-via-UART-and-monitoring-signa...

 

Regards,
Robert V

 

736 Views
HarryQi
Contributor III

Hello, @robertv ,

Thank you so much for all the support you offer! Now i can use the EVB  successfully to realize the function with the Flexcan module,  so thank you for your help !

Best Regards

HarryQi

 

 

0 Kudos
973 Views
HarryQi
Contributor III

Hello, @robertv ,

Thank you so much for your reply!

I did what you said ,but i still can't make it work ,i attach my initialization screenshot here,and .mex file ,could you help me  check whether it is right ! Thanks again !

 

0 Kudos