PSoC 4 doesn't officially support LIN master. We highly recommend you to test the example with a LIN master emulator instead of using a PSoC.
But having said that, it should be possible to use SCB UART Component to act as LIN master (but not guaranteed / tested to work). But we do not have an example to showcase the same.
In the start guide it is showed how to test the LIN Slave example with the CY8CKIT-042 and a LIN master emulator.
I see the frame "ID CMD FF FF FF FF FF FF FF" is introduced through the graphic interface. I am trying to do the same but with the UART instead. I would like to know if the master emulator does something inside. I mean, does the field ID=0x10 includes the parity bits or are they calculated, the MSB goes left to right or is the opposite, is there a checksum at the end of the CMD frame or not, etc.
If I could know what kind of frame is specting the slave to recive I would be happy to try. I have tried several combinations, but it does not seem to work.
Thanks in advance.
1. When you are trying to send commands through the PSoC LIN Master, you need send frame ID with parity. In the slave node, when you mention the Frame ID to be 0x10, it refers to only to the 6 bit frame ID. You can use the below formula to calculate parity.
or it is better to use the 2.8.2 TABLE OF VALID FRAME IDENTIFIERS (Revision 2.2A ; Page 53) from the LIN SPEC that lists the PID byte for all possible frame identifiers. For example, in case you need to send 0x10 Frame ID, you can send 0x50 PID.
2. Yes, when the master is sending the header frame with response frame, you need to send it with Checksum. See section 220.127.116.11 Checksum for details.
3. LSB is sent first and then the MSB (little endian).
4. Make sure Autobaud rate is enabled in the slave side.
Please check Local Interconnect Network (LIN) Slave Component User Guide for PSoC - KBA225227 for details.
Yes, I have also been trying that way.
The frame I am trying to send is:
Break (13 bits) -> Sync (0x55) -> ID (0x10) -> Message (0x22)(0xFF)...(0xFF) -> Checksum (0x99).
The ID with parity bits is 0x50 as you said.
If I change the order of the message (0x22), it becomes (0x44) since LSB is at the beggining.
I have used the same checksum (0x99), it has the same value with the LSB at the beggining or at the end. It didn't work, so I tried getting the checksum from the frame (0x44)(0xFF)...(0xFF), which is (0x83) and tested it also backwards (0xC1). It stills failling.
I don't know what am I doing wrong. The Auto baud rate is active in the LIN slave, I think you meant in the configuration graphical interface. I have tried using 2400 and 9600 bauds instead of 19200 on both sides (Master and Slave).
Both NSLP pins are connected to 5V.
Is there any Sleep mode I am missing? If not, I don't know what more can I do.
PS: I guess the sync frame must be 0x55 and not 0xAA, right?
Thanks for your replies, BragadeeshV_41.
The checksum you have calculated is incorrect. Please use the attached main.c that has a sample checksum calculation. Please refer LIN spec section "2.8.3 EXAMPLE OF CHECKSUM CALCULATION". I hope you are doing enhanced checksum (including PID for checksum calculation)
Any chance you can get a LIN master emulator?
main.c.zip 840 bytes
Thank you very much, BragadeeshV_41.
My project is now working fine. I have achieved to act as a master and change the leds on the slave.
In the sample project the ID is 0x10. So, in the LIN protocol 2.2 I obtain the Protected ID (PID) 0x50.
The commands the slave con receive are 0x11, 0x22, 0x33 and 0x00.
Through the C code you have shared, if I want to obtain the Checksum for the command 0x22, I have to put the PID and the Command Frame:
Frame= 0x22, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
In this case, I obtain the checksum 0x8D.
So... The complete frame I have to sed through the UART is the following:
Break (13 bits).
0x22, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF //Frame
This is the order, it is not necessary any bit rotation. I hope this explanation to be usefull to others with the same doubts or problems.