Slave response S12P64 or S12P128

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Slave response S12P64 or S12P128

1,134件の閲覧回数
karimaaissaoui
Contributor II

Hello,
I wonder if the S12P64 OR s12p128 microcontroller supports sending LIN master requests and receiving slave responses at the same time or not, because I can't recieve the slave responses after sending a LIN query of DLC 0.

Waiting your feedback.

Thanks in advance.

ラベル(1)
7 返答(返信)

888件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi Karima,

I suppose that this is a misunderstanding.

The LIN bus is one wire communication and LIN slave may response only when LIN master requests it.

The LIN PHY displays LIN bus activity on RX pin, despite on fact whether this data are generated by the master or by a slave. So, the master and slave cannot communicate simultaneously – otherwise, it is error behavior.

 

The LIN communication at S12P is managed by SCI module at a low level. However, the LIN protocol implementation is based on a software solution.

 

From hardware point: please check whether LIN PHY is powered by the 12V power supply and check communication by an oscilloscope.

If you use your own board, please check whether you connected RXD pin on MCU with RXD pin on LIN PHY the same way also TXD pin.

If you use LIN PHY with more features, please check also the correct connection of inhibiting, sleep, wake-up,…. and other pins.   

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!
-----------------------------------------------------------------------------------------------------------------------

888件の閲覧回数
karimaaissaoui
Contributor II

Hi Radek,

Thank you sooo much for your answer.

I work on a CAN / LIN card based on the microcontroller HCS12P64, it convert frames in both directions from CAN to LIN and from LIN to CAN without problem.
The problem is that It can't receive answers LIN Slave when sending requests LIN by CAN. According to the tests that I done: the Slave responses arrive at the Transceiver LIN, without being able to recover them in the microcontroller.
The connection is well made between the microcontroller and the transceiver.
I don't know why the card can convert the frames in both directions without being able to retrieve the slave responses.

Thank you in advance.

Best regards.

0 件の賞賛

888件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi Karima,

If I understood correctly, the CAN / LIN card with S12P MCU is bidirectional.

This implies that the CAN / LIN card should be LIN master node and the LIN slave is some different device. Right?

If the CAN / LIN card cannot receive an answer from the LIN slave, how you send data from LIN to CAN?

 

If it simply works for one LIN slave (as a source of data) and does not work for second LIN slave, the problem will be probably in software.

From the hardware point of view, please check LIN baud rates include tolerances.

 

The CAN / LIN card software should be configured for different actions based on some commands.

I am afraid that the issue cannot be simply debugged without deep knowledge of LIN bus topology/parameters and S12P software.  

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!
-----------------------------------------------------------------------------------------------------------------------

888件の閲覧回数
karimaaissaoui
Contributor II

Hi Radek,
Thank you once again for your answer.
When I send a frame CAN of DLC 0 it converts it into LIN frame, I receive it in the BUSMASTER, and when I have a slave response on this query, the answer appears in Busmaster, but I can't retrieve it from the CAN side on an other BUSMASTER.
Knowing that I can translate a frame from LIN to CAN.
I wonder if the microcontroller can't retrieve the answer just after sending the queries.
Please send me some codes in this direction if possible, I will be very grateful.
I have read too much on the LIN bus and architecture of the HCS12P, but I have not found a solution for this problem until now.
Another point : I wonder how I can check the transmission rates of LIN include tolerances, from the hardware point of view?
Thank you very much for your help.
Best regards.

0 件の賞賛

888件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi Karima,

Thank you for more details.

The MCU itself can send and receive serial data via SCI module.

The LIN protocol implementation is almost pure software solution (except few features, like BRK signal,..).

So, if MCU does not send LIN slave answer, the CAN/LIN card is not programmed/configured for that task.

 

Unfortunately, I am not aware of any CAN/LIN card example code. In the attachment, you may find very simple example code for basic LIN communication at S12P. more complex example codes are part of our LIN stack:

http://www.nxp.com/assets/downloads/data/en/device-drivers/FSL_LIN_2.X_STACK.zip

 

I am sorry, I should use rather a bit rate instead of baud rate.

The maximum LIN bitrate is specified as 20kbit/s per LIN specification (e.g Rev1.3). While the most typical bit rates are 9600bit/s or 19200bit/s. When you see LIN master request and LIN slave response on transceiver side, you may measure bit time and calculate master and slave bitrates.

The bit rare tolerance depends mainly on clock source. The LIN specification requires total clock tolerances <= +/-2%. So, the small difference between master and slave bit rate should not be a problem until it stays in this area.

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!
-----------------------------------------------------------------------------------------------------------------------

888件の閲覧回数
karimaaissaoui
Contributor II

Hello Radek,

Thank you for the documents you provided, they are very interesting.

I tested the LIN project that you gave me (S12P-LIN), and unfortunately the main function does not allow me to receive a LIN frame, here is the piece of code that I used to test it.

I used Var1, Var2,Var3, just to know if we  enter to  functions, and I didn't use the test if Master or Slave.

All variables don't change!!

if (LINCheckState(LIN_0) == CHECKSUM)
{
         Var1++;
if (LINGetMsg(LIN_0, TRUE, &msg_get_LIN))
 {       Var2++;
if (msg_get_LIN.identifier == 0x07)
{         Var3++;
         msg_send_LIN.identifier=0x09;
         for(i=0;i<8;i++)
         {

         msg_send_LIN.data_field[i]=0x09;

         }
(void)LINSendMsg(LIN_0, TRUE, TRUE, msg_send_LIN);

}
}
}

Thanks in advance.

Best regards.

0 件の賞賛

888件の閲覧回数
RadekS
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------