S32K144 MBD CAN configuration

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K144 MBD CAN configuration

Jump to solution
437 Views
Contributor I

Based on S32K144, how to configure the CAN on Simulink/Matlab in order that we can recieve a few(not one)messages? Is there any examples?

Thanks for your answer!

1 Solution
85 Views
NXP Employee
NXP Employee

Hello 1750632@tongji.edu.cn ,

I would suggest you watch Introducing the CAN Communication Blocks from NXP MBDT | NXP video - you can skip the first part as it mainly talks about how CAN was introduced and how the protocol works; after that it goes through some examples.

Mainly what you'll want to do is set-up the acceptance filter - this means that in the receive block, you'll set-up the ID and mask so that it fits your acceptance criteria (the range of IDs you want to accept).

It works like this:

(ID & mask) == (incoming_ID & mask) ? 

Where ID and mask are the ones you set-up in the Simulink block and incoming_ID is the ID of the message on the bus. To put it simpler, you just have to put a '1' bit in the mask on the position where you want the incoming_ID to match the ID, and '0' bit where you don't really care what bit is there.

I hope this clarifies things a bit.

Kind regards,

Razvan.

View solution in original post

7 Replies
86 Views
NXP Employee
NXP Employee

Hello 1750632@tongji.edu.cn ,

I would suggest you watch Introducing the CAN Communication Blocks from NXP MBDT | NXP video - you can skip the first part as it mainly talks about how CAN was introduced and how the protocol works; after that it goes through some examples.

Mainly what you'll want to do is set-up the acceptance filter - this means that in the receive block, you'll set-up the ID and mask so that it fits your acceptance criteria (the range of IDs you want to accept).

It works like this:

(ID & mask) == (incoming_ID & mask) ? 

Where ID and mask are the ones you set-up in the Simulink block and incoming_ID is the ID of the message on the bus. To put it simpler, you just have to put a '1' bit in the mask on the position where you want the incoming_ID to match the ID, and '0' bit where you don't really care what bit is there.

I hope this clarifies things a bit.

Kind regards,

Razvan.

View solution in original post

85 Views
Contributor II

i have the same question. i don't know how to have a correct configuration to receive multiple messages from different IDs. The examples i find in MBDT can only receive messages from the same ID, what if I have a huge number of messages from different IDs on the same bus? 
And if i receive and send multiple messages, i don't know how distribute interrupt timer.

really want to get some examples!

0 Kudos
85 Views
NXP Employee
NXP Employee

Hello bearman.m ,

I hope the reply I put earlier clarifies how to set-up the CAN to get an entire range of IDs. I would suggest you watch the same video (Introducing the CAN Communication Blocks from NXP MBDT | NXP ) - there it shows some examples for setting up the range.

As for the interrupt timer, I'm not really sure I understand your question. We have support for interrupt timers in the form of PIT blocks. There you can set-up the timers to give you an interrupt over a certain period (user-defined). The number of such independent interrupts is dependent on the number of channels available on the MCU you are using. You could get to a higher number, but with a bit of software involved (not pure hardware interrupts).

Maybe give me an example on what you are trying to achieve so I understand a little better what you are having issues with.

Kind regards,

Razvan.

0 Kudos
85 Views
Contributor II

Hi Razvan,

I am honored to receive your reply. I want to receive messages from two different IDs and i want to send with two different IDs for what we have received. i cant find the way to give you my file. i will put some photos.

pastedImage_1.png 

1.In the Tx part's function-call subsystem:

pastedImage_2.png

1.1 in the FCAN_Isr's function-call subsystem:

pastedImage_3.png

in the case action, we have two LED to toggle so we can know that we have received the messages, and  we save these received data to 2 memory blocks and them send them with two differet IDs.

2.In the TX part's function-call subsystem:

we use two blocking TX parts to send these two kinds of messages.

pastedImage_4.png

The situation we encountered is that:

1. If we delete the whole "Tx parts", we can observe that the LEDs defined in 1.1 are Flashing, thus we konw that the MCU received the mesaages.

2. If we dont delete the "Tx parts", we can oberve that the MCU sents the 2 messages defind in 2., but LEDs are not flashing and the truth is , MCU can not receive messages any more.

We are new to MBDT and this kind of MCU.

I don’t know if what configuration caused this result, so I’m confused. Hope you can help me, thank you very much

85 Views
NXP Employee
NXP Employee

Hello bearman.m,

I would apreciate if you could send the model -- easier to follow than in the images. Can you select different message buffers (MB) for every block and see if you still have issues? 

Kind regards,

Razvan.

85 Views
Contributor I

I had a try about that. It's useful to solve the problem. So I want to know the meaning of the "buffer". And what should we do if the number of messages is more than that of the buffers(add up to 32) ?

Thank you again!

0 Kudos
85 Views
NXP Employee
NXP Employee

Hello 1750632@tongji.edu.cn ,

First of all, for each MB used you can select an entire range of messages - so you can map any amount of IDs to 1 MB. In the unlikely scenario where you have more than 32 ranges selected, you can multiplex a MB as long as you are careful in regard to the timing - you should make sure 1 operation is fully finished before the next one starts; otherwise it will just abort the first one.

If you want to read more about message buffers, you can check the reference manual for S32K1xx, in chapter 53.4.3 Message buffer structure and 53.5 Functional description.

Kind regards,

Razvan.