Hi Karima,
Could you please answer first whether you program LIN master or LIN slave node? This is quite important “detail”.
This simple example code does not exactly refer to your required functionality – the LIN master measure ADC value and send it to LIN slave.
The condition if (LINCheckState(LIN_0) == CHECKSUM) at LIN slave code checks whether the whole message was received.
The LIN message principle.
If you want to get an answer from the slave, the master has to start the message by sending synch break, synch field, and an identifier field. The slave has to check identifier field and if it fits predefined value, the slave will continue in transmitting data fields followed by CRC check field.
Please look at Figure 2.2: Communication Concept of LIN in LIN specification Rev1.3.
So, if you program LIN master, you should use LINSendMsg() function while the third input parameter “send_data” will be FALSE.
So, if you program LIN slave, you should wait for lin state PROTECTED_IDENTIFIER and if msg_get.identifier is equal to predefined ID “e.g. _ID”, and use LINSendMsg() function with the second input parameter “master” FALSE for sending slave’s data to master.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------