I have an NXP S32144 and I trying to set a very simple communication via CAN Protocol between an Arduino Uno with an MCP2515 additional module.
From the Arduino side, the program is very simple because I can use the library mcp2515.h which have the availability of some "high-level" function io order to set the id, the doc, and the data content. Further, in order to receive a message, once you initialize an adequate type of structure in which save the current message, you can access to that structure in a simple way and read the various field of the message itself; and in order to write, similarly, you initialize that kind of adequate structure and assign the value you want to any field.
I expected something similar for NXP but is not so.
My try is the following:
- open an example from Design Studio: FLEX CAN
- and I have modified in the following way the main.c, FlexCan.c; and FlexCan.h :
3)in the FlexCan.h I just inserted the command line uint32_t ID_rx(void);
My idea is to save only the id of the currently received message in a variable (which clearly change any time that one new message arrives) and as a starting point I just want to print and after a control (in which I simply increment a counter variable to decide when turn on the green led).
I have tried to built and no problems occur but when I try the debug_ram procedure (clicking play button) i notice that on the console the printed id is always "0x0".
I also noticed that the led turn on when a click plays in the debug procedure, but this is strange because also if the reader id is wrong, the "if" condition is not satisfied.
Intuitively I understand that the FlexCan_init function must be modified but I do not know how in order to read any message received.
If someone can explain also the various function in order to understand how modify if I want to not only receive all possible can message, but also if I want to transmit a specific id with a specific periodicity
I do not have enough knowledge of embedded system or experience in programming, so maybe my problem is trivial but hopes someone can help me.
Thanks in advance to who spent the time to help me.