MPC5744P CAN

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC5744P CAN

1,435 Views
seize
Contributor III

Hi

I am using MPC5744P-144DC evaulation board and trying to use FlexCAN module on it.

I looked into two exampels, "MPC5744P-FlexCAN-simpleTXRX-GHS614" and "MPC5775K-FlexCAN_with_interrupts-S32DS_Z4_1"

On examples, DATA filed of CAN message was setting byte base as follow;

CAN_0.MB[MB].DATA.W[1] = 0x90ABCDEF; //data1 set
CAN_0.MB[MB].DATA.W[0] = 0x12345678; //data0 set

How can I set a data longer than 1 byte? 

For example, I need to put motor speed (14bit) in DATA[0] (0~7 bit) and DATA[1] (0~5bit) and Motor status (2bit) in DATA[1] (6~7bit). 

Best regards,

Hyuntae Choi

Labels (1)
4 Replies

458 Views
martin_kovar
NXP Employee
NXP Employee

Hello,,

FlexCAN allows you to send 1-8 bytes in one message. There is DLC in message buffer structure which says, how many bytes is sent in CAN message. In the example you showed above following code is used.

CAN_0.MB[MB].CS.B.DLC = 8;              //message length 8 bytes

So you must set the required number of bytes and then, you can configure DATA itself.

Instead of DATA.W, which configure whole word, you can use DATA.B and set every byte independently.

For example, if you want to send 2 bytes, configuration should be following:

CAN_0.MB[MB].DATA.B[0] = 0x12;   //first data byte

CAN_0.MB[MB].DATA.B[1] = 0x12;  //second data byte

CAN_0.MB[MB].CS.B.DLC = 2;              //message length 2 bytes

Hope it helps.

Regards,

Martin

458 Views
seize
Contributor III

Dear Martin,

Thanks for your kind reply.

What if I need to send two signals as in the example [For example, I need

to put motor speed (14bit) in DATA[0] (07 bit) and DATA[1] (05bit) and

Motor status (2bit) in DATA[1] (6~7bit). ]

Motor speed = 0x2a11 which is 14 bit signal and motor status is 0x3 which

is 2bit signal.

And I need to send above two signals with DATA.B[0] and DATA.B[1].

In order to send two signals, do I need to put first 8 bits of motor speed

in DATA.B[0] and last 6 bits of motor speed and 2 bits of motor status in

DATA.B[1], which is very uncomfortable?

In this way, I need to reconfigure both signals whenever send data.

Is there any function like setting the start bit of signal and length of

signal?

For example, start bit of motor speed signal = 0 and signal length of motor

signal = 14 bit, start bit of motor status signal = 14 and signal length =

2 bit.

Thanks for your support in advance.

Best regards,

Hyuntae

2017-05-16 16:56 GMT+09:00 b55689 <admin@community.nxp.com>:

NXP Community

<https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>

Re: MPC5744P CAN

reply from Martin Kovar

<https://community.nxp.com/people/b55689?et=watches.email.thread> in

MPC5xxx - View the full discussion

<https://community.nxp.com/message/905775?commentID=905775&et=watches.email.thread#comment-905775>

0 Kudos

458 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

I am sorry, but I do not understand your question. FlexCAN allows you to send message with 1-8 bytes. It is up to you, how you configure it. Please remember that CAN data frame does not contain data only, but there are another fields like Arbitration, Control, CRC etc., please see figure below.

pastedImage_1.png

"In order to send two signals, do I need to put first 8 bits of motor speed in DATA.B[0] and last 6 bits of motor speed and 2 bits of motor status in DATA.B[1], which is very uncomfortable."

But this is the only way how to use it. FlexCAN always send 1 byte data, so if you have 14 bits you need to send, you must send frame with two data bytes.

Is there any function like setting the start bit of signal and length of signal?

Unfortunately, no. FlexCAN does not have this function. Data are also divided into 1 byte blocks.

Regards,

Martin

458 Views
seize
Contributor III

HI Martin,

Thanks for your kind reply. My question is cleared with your answer.

Regards,

Hyuntae

2017-05-17 20:13 GMT+09:00 b55689 <admin@community.nxp.com>:

NXP Community

<https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>

Re: MPC5744P CAN

reply from Martin Kovar

<https://community.nxp.com/people/b55689?et=watches.email.thread> in

MPC5xxx - View the full discussion

<https://community.nxp.com/message/906240?commentID=906240&et=watches.email.thread#comment-906240>

0 Kudos