S32K144 CAN problem

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

S32K144 CAN problem

8,438 Views
huaping
Contributor III

we are using S32K144 Flexcan, and MB1 receive through interrupt, and find the data is stored in EmbeddedRAMx.

we want to interpret these data,but we don't know these meanings, pls see the attached file.

also do you have the examples using CAN FIFO mode?

Thanks a lot!

9 Replies

4,987 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

If 8 data byte payload size is used then four EmbeddedRAMx words represents single Message Buffer, as following for MB0

pastedImage_1.png

MB1 belongs to EmbeddedRAM4-7, and so on...

I have modified the CAN_MASTER_example to enable the RXFIFO. You can test it on the EVB.

The internal loopback is enabled so single board can be used. The MB8 is used to send a message upon button press and is received through RXFIFO.

Hope it helps.

4,987 Views
jay_zhang
Contributor II

Hi Petr,

I have another issue about flexcan on s32k144, can you help to resolve?

https://community.nxp.com/thread/481750 

0 Kudos
Reply

4,988 Views
sakthivelkuland
Contributor III

Hello,

I have gone through the Discussion,

I need help on the FleXCAN details are,

I'm working on S32K144 MCU for My TPMS Application, My requirement to use the CAN with Extended the ID Format,

For Startup, I have used the Non-SDK FlexCAN Example to test the CAN Communication(MCU CAN_TX Pin) transmission, But unfortunately, this example Not working on EVB.

I can't see ant Data format signal with a scope, I have tapped the MCU CAN_TX Line.

Testing example found the CookBook documents Number: AN5413

Note: My Project used Non-SDK.

Please help me with this issue.

Thanks,

Sakthivel K

0 Kudos
Reply

4,988 Views
huaping
Contributor III

Dear:

      I import your example, but failed to compile it, there any many errors.

      Pls help check the attached files for errors.

Thanks!

0 Kudos
Reply

4,988 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

which version of S32DS you use? Did you try to open it in version 1.3?

I have just tested in 1.3 and it works correct on my side. Could you please try to import project once again, clean project at first and then compile?

Have you already installed Update1? If no, could you please try to install and test the project once again?

https://community.nxp.com/docs/DOC-333898 

Regards,

Martin

0 Kudos
Reply

4,987 Views
huaping
Contributor III

Hi,

    After update S32 DS V1.3, and change SDK  path, it works. But I have another problem when I use interrupt mode.

    It can enter RX interrupt function every time, but it only sends out data in the first time. From second time, no data is sent out.

    Would you pls help check my attached example?

    Also, Is there any example to guide me how to use RX FIFO? How can I know which MBx is stored, and how to do it?

    Thanks a lot!

0 Kudos
Reply

4,986 Views
mikhail_l
Contributor II

Hi Petr,

I also modified CAN examples to work in FIFO mode. It works, but I see unexpected data byte swapping/reversing in every 4 byte group on the receiving side in RX FIFO. 

I send 8 bytes: 0,1,2,3,4,5,6,7.

In RX FIFO I see: 3,2,1,0,7,6,5,4.

Did you see anything like that with your code and board?

PS: I do not see that problem in normal mailbox mode (without FIFO).

My changes to the example project are very similar to yours, but I do not use loopback. I use another board to transmit instead.

Also noticed you have ".fd_enable = true" in SendCANData(), but maybe it is ignored by driver since module is not in FD mode.

Thanks,

Mikhail

0 Kudos
Reply

4,986 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Mikhail,

The module itself does not do any byte swapping.

Seems the API itself does swapping. See how the receive buffer is filled from MBx or RXFIFO in functions FLEXCAN_HAL_ReadRxFifo() and FLEXCAN_HAL_GetMsgBuff().

Note the S32K144 is little endian device.

 

Here is a memory map when

 

uint8_t txBuffer[8] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88};

 

is send with

 

SendCANData(TX_MAILBOX, TX_MSG_ID, &txBuffer[0], 8UL);

 

using the MB8

 

The debugger is stopped in FLEXCAN_DRV_IRQHandler, the RXFIFO is at address 0x40024080

 pastedImage_1.png

I see no byte swap in RXFIFO. data from MB8 is received in the same order as it should.

The same memory window from S32DS

 pastedImage_2.png

BR, Petr

4,986 Views
mikhail_l
Contributor II

Hi Petr,

You are right! 

In FLEXCAN_HAL_GetMsgBuff() they use REV_BYTES_32() to convert the data to little endian, but in FLEXCAN_HAL_ReadRxFifo() they do not do swapping and therefore data ends up being reversed.

Thanks!

Mikhail

0 Kudos
Reply