Hi,
I'm using RL78 F13 48 pin controller with LIN.
LIN IC used is TJA1021 - Master.
2 slaves are connected to the master & in while loop in 50 ms timer interval i am trying to transmit header to both the slaves one by one to receive data.
If i add around 2.5 ms of delay between both transmissions - LIN communication is working fine.
Otherwise I'm unable to get data from LIN.
-------------------------------------------------------------------
Example:
Works fine with a delay between 2 transmissions.
LIN_Master_HeaderTransmit(0x81); //LIN Slave 1 for(int i =ZERO; i<=2500; i++) { Wait1us(); } LIN_Master_HeaderTransmit(0x82); //LIN Slave 2
----------------------------------------------------------------------
The below code does not work:
LIN_Master_HeaderTransmit(0x81); //LIN Slave 1
LIN_Master_HeaderTransmit(0x82); //LIN Slave 2
We are not supposed to have a delay in the program, so kindly let me know your comments on this.
Is the delay expected ? or will it work without the delay?
Thank you.
Hi Vish,
What inter-byte space have you set ?
https://www.renesas.com/us/en/document/apn/rl78f13-f14-f15-setup-procedure-lin-communication-master-mode-guidance-rev100?r=1054256
Regards
Inter-byte space LSC is set to 0x11
Inter-Byte Space (Header)/ Response Space Select - 1 Tbit
Inter-Byte Space Select - 1 Tbit
----
The above delay scenario, I'm able to resolve by adding a flag and waiting for one slave communication to complete before starting the next.
As per my understanding it is not possible to transmit data to/Receive data from same LIN slave at the same time. So, some time difference is required between both the communications when the it is the same Slave.Please let me know your comments on this.
What you are trying is to transmit data on the same LIN bus, for 2 different slaves but this is not possible. You need to either for the first transmission to end and then start the second, or use 2 separate LIN buses for each slave device.
Thank you for the explanation.
I have only one LIN bus(one master) so "waiting for one slave communication to complete before starting the next" resolves the problem. (1 Master - 2 LIN slaves)
(Please correct me if my understanding is not correct)
I have one more question, I have one LIN slave. LIN Master is trying to get data from LIN Slave and also trying to send data to same LIN Slave one after another. In this case the communication is failing.
What can be done during such scenarios!
If I understand correctly, do you want your master to transmit and receive data simultaneously ? That is not possible in LIN as it has only 1 wire bus and it is half duplex. The LIN transceiver converts the full-duplex RXD/TXD interface into a 1-wire half-duplex interface.
I understand your explanation.
No, not simultaneously.
I would like to know if Master transmits data (1st function) then as a next function if it tries to receive the data. (Function calls one after another), some delay(wait) time between both transmit and receive are expected ? What can be done in such scenarios !
The best way to do this is to wait for the send end interrupt and then start receiving data. Similarly, you can wait then for the receive end interrupt and then start the next function. Of course this will require some processing inside the ISRs.
You can do this with delay but it would not be as efficient.
Thank you for the clarification.