cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

New Contributor

Hello.

I am trying to set-up a LIN Master-Slave communication.

The configuration I have made is in the following scheme:

LIN-Boards-Scheme.png

I am using 2 boards.

  • CY8CKIT-042-BLE: It is the master. Is sending a frame every second to the slave. It does it using the UART communication, which is linked to the CY8CKIT-026 LIN_TX and LIN_RX. The signal goes to the LIN transducer, which converts the 3.3V signal in 12V.
  • CY8CKIT-042+026: They are the shield and the microcontroller. It is suppoused to receive the signal thrugh LIN, the transducer converts it back to 3.3V and the running program should read the signal and change the color of a led situated on the 042 board.

For this operation I programmed a UART for the CY8CKIT-042-BLE, and I am using the cypress kit example on the CY8CKIT-042. I am uploading the project to this post.

If it is useful, I am also posting the oscilloscope adquisition:

lin.jpg

I am sending a 13 bits break, a 0x55 for sync porpouses and then the identifier 0x10 followed by the 8 bytes command 0x22, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF.

Since there is not an example nor an API for LIN Master, i am in doubt about which command is the software expecting at the slave side. I have tried with different frames in order to include the parity bits in the ID frame and also the checksum at the end of the command. Anybody has done the same before and is able to guide me?

Thanks in advance.

0 Likes
Reply
1 Solution
Moderator
Moderator

Hi user_4695846​,

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?

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
Reply
7 Replies
Moderator
Moderator

Hi user_4695846​,

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.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes
Reply
New Contributor

Thanks BragadeeshV_41​.

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.

0 Likes
Reply
Moderator
Moderator

Hi user_4695846​,

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.

pastedImage_0.png

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 2.3.1.5 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.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes
Reply
New Contributor

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.

Doubts:

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​.

0 Likes
Reply
Moderator
Moderator

Hi user_4695846​,

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?

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
Reply
New Contributor

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:

PID=0x50

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).

0x55 //Sync

0x50 //PID

0x22, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF //Frame

0x8D //Checksum

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.

0 Likes
Reply
Moderator
Moderator

Hi user_4695846​,

We are glad that your project is working now

I've edited the main.c in the previous response to use 0x50 (with parity).

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes
Reply