CAN Receive

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

CAN Receive

2,671 Views
fernando_barrio
Contributor III

Hi,

I am working with a S32K144 using Simulink & the new toolbox (R2018), I can send messages on the bus, however I am having difficulty reading from the bus. I have tried the CAN example model, but the light seems to blink even if I don't send the CAN message so it hasn't been very helpful for troubleshooting. On my project I implemented the same receive format and I am using FreeMASTER to check the variables, but the messages aren't being received. I have attached my model below, it just receives messages from a joystick and sends out one steering command. Please let me know if you guys have any suggestions.

Thank you in advance.

Tags (1)
11 Replies

2,019 Views
fernando_barrio
Contributor III

Hi constantinrazvan.chivu‌,

Thank you for your reply, I have done this before and have been able to send out CAN messages with extended ID without a problem. It is just receiving the messages that doesn't work. I have it setup the same way as the example, when is the ISR suppose to run? From using FreeMASTER it looks like the routine runs once when I first start the code then no other CAN messages are read.

Thank you,

Fernando

0 Kudos

2,019 Views
gramirezv
Contributor III

Hola fernando.barrios@uwaterloo.ca‌,

I think the problem you may be seeing is because you have to include the receive blocks inside the CANReceive\RX_Complete block also.

pastedImage_3.png

These blocks are the same you're using on the init block (the one that runs only once on startup with the init_flag), this block setup your initial CAN Receive messages and then you have to include your receive blocks every time a CAN message has been received. So, when the FCAN_Rx_Complete_Isr calls your Rx_Complete block you are able to receive the subsequent CAN messages.

Regards,

Gustavo

2,019 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca

It seems that  gramirezv‌ has spot this other issue before I did. Thank you for that Gustavo! He is right - you have to call the CAN Receive blocks inside the ISR calls, so you can continue receiving other CAN messages.

Kind regards,

Razvan.

2,019 Views
fernando_barrio
Contributor III

Hi constantinrazvan.chivu‌ and gramirezv‌,

I would like to use Rx FIFO, then at the beginning of my program check if there is any new messages in the mailbox and use the updated value for that cycle of calculations. In this case would I still have to use the ISR block? I don't see any other way of retrieving the data.

Thank you,

Fernando

2,019 Views
gramirezv
Contributor III

I ran into the exact same issue while testing my CAN interface, that's why the description of the problem sounded very similar to me.

0 Kudos

2,019 Views
fernando_barrio
Contributor III

gramirezv‌ are you using extended CAN as well?

0 Kudos

2,019 Views
gramirezv
Contributor III

Hi fernando.barrios@uwaterloo.ca‌,

Yes I'm using extended CAN as well, I'm working with J1939.

I would recommend you start from a single message and go from there. Since you have your CAN interface working and you are able to transmit messages you know your physical layer is working. I haven't gone deep using the CAN interface as I was doing only testing for evaluating the s32k144, but I would suggest you to do the following:

  • Create the RX message for only one ID, let's say CFDD6EB. Do the Init RX and then in the ISR add the blocks for receiving only this message.
  • Assuming you're using CANalyzer connect your two buses (CH1 & CH2) together and start transmitting from a IG block in CANalyzer a message with the CFDD6EB, let's say at a rate of 100 ms. Start CANalyzer and you should see the messages being TX on CH1 and RX on CH2. One thing I noticed is that your CAN bus has to be active when you start your S32K144EVB or your CAN interface doesn't work (I haven't figured out why yet, I assume it has a time out and goes to bus off or something similar). That's why you should start CANalyzer first and have activity on the CAN bus. Then power up your S32K144EVB
  • If you are using FREEMASTER, you should see the data you are transmitting from CANalyzer.

Best regards,

Gustavo

2,019 Views
gramirezv
Contributor III

Hi fernando.barrios@uwaterloo.ca‌,

I'm attaching the model I used to test rx and tx of extended ID messages over CAN. This example transmits a 0x18FF0000 message and receives a  0x18FF0100 message.

Regards,

Gustavo

2,019 Views
fernando_barrio
Contributor III

Hola gramirezv‌,

This is great, I really appreciate your help. I will test it out on the weekend!

Thank you,

Fernando

2,019 Views
fernando_barrio
Contributor III

Hi ‌constantinrazvan.chivu and gramirezv,

I appreciate your suggestions I have added all three of the FCAN receive blocks into the CANReceive\RX_Complete block and also into each case block. However, I am still not able to see any content being received by the NXP, but I can see it with a Vector CAN tool. Do you guys have any other suggestions that may not be allowing me to see anything? I have simplified the model a bit for testing purposes with no luck.

Thank you,

Fernando

0 Kudos

2,019 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

I think you are facing some issues because you are using extended ID. We fixed this in a previous thread, but just now created a page dedicated to S32K14x 2018.R1 hotfixes - you can find it here.

Please follow the steps for hotfix 1 - this should fix your problems. Please let us know if you are having other issues.

Kind regards,

Razvan.

0 Kudos