LIN  diaganostic problem,

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LIN  diaganostic problem,

Jump to solution
4,054 Views
deepakchandra
Contributor III

we are using s12zvl32 uc in our actuator project.we are facing problem in using LIN stack for diaganostic class , i have read in some reference to add diaganostic we have add #include "lin_lin21tl_api.h" and then add the below code in main,but we are unable to read any data from LIN .

we are using first time the LIN diaganostic, if there any reference manual /any example how to use LIN diaganostic function in project please send me ASAP .

here my fist task is to read by identifier

 

#if _TL_FRAME_SUPPORT_ == _TL_MULTI_FRAME_

  if(diag_get_flag(DIAGSRV_READ_DATA_BY_IDENTIFIER_ORDER)){

  l_u16 req_len = 0;

  l_u8 req_data[10];

  diag_clear_flag(DIAGSRV_READ_DATA_BY_IDENTIFIER_ORDER);

  /* Process data */

  ld_receive_message(&req_len, req_data);

  req_data[0] += 0x40;

  /* Send response */

  ld_send_message(10, req_data);

  }

  #endif

 

please help me out from this problem ,we are in between the project and we have complete the project in  2 week ,half of my project is completed .

iam sending u my LDF file also .

Original Attachment has been moved to: LDF_example.ldf.zip

Original Attachment has been moved to: NPF_unity.npf.zip

Labels (1)
1 Solution
2,283 Views
RadekS
NXP Employee
NXP Employee

Hi deepak,

1. According to LIN Specifications, the Read by Identifier should be as follow:

Read by Identifier request.png

It seems that you made wrong command data.

                The correct command should be (based on data in LDF_example.ldf):  0x09 0x06 0xB2 0x00 0x0F 0x00 0x10 0x00

ALIN_2 {

LIN_protocol = "2.1"; /* Node protocol version */

configured_NAD = 0x9; /* configured NAD of node (1-125) */

initial_NAD = 0x9; /* initial NAD of node (1-125) */

product_id =    0xf,  0x10,    0x2; /* Product id */

response_error = ALIN_2_RsErr; /* Response error signal */

P2_min = 50 ms; /* P2_min */

ST_min = 0 ms; /* ST_min */

N_As_timeout = 1000 ms; /* N_As timeout value */

N_Cr_timeout = 1000 ms; /* N_Cr timeout value */

configurable_frames {

ALIN_2_Stat_Frm;

ALIN_Rq_Frm;

}

2. If the Master want to send Sleep mode command, users can use command:

l_sch_set(LI0, LI0_GOTO_SLEEP_SCHEDULE, 0);

then the Master will send go to sleep command to all slaves, and it also will switch to sleep mode.

In order to wake up, the Master should send l_ifc_wake_up(LI0); and switch schedule table to normal table.

In sleep mode, we have not implemented power save mode yet. It was decided that users application should implement that.

Please let me know whether you have any doubts about MCU power save modes (WAIT/STOP/Pseudo STOP).

3. After successfully changed NAD, the Configured NAD was changed to new NAD that is 0x22. But after reset, then the NAD is restored back to configured NAD in LDF file that is 0x09.

By the way, in the LDF_example, the Configured_NAD for node ALIN_2 is 0x09. but his commands were using NAD 0x06. This is also one possible reason, the slave did not answer.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

6 Replies
2,283 Views
RadekS
NXP Employee
NXP Employee

Hi deepak,

I received an example project from LIN stack designers to demo the diagnostic communication as you desires.

Please backup and replace 2 project examples in LIN Stack by these 2 attached projects

<LIN_Stack>\Examples\S12Z_examples\Knox_S12ZVL

This example is prepared for LIN Stack v4.5.4 (I guess this is version which you using).

In this demo:

1)    Please note that for master node board, pins 1 and 2 of J50 should be connected

2)    S12ZVL32 LIN Master uses GPA table as normal communication schedule

3)    Whenever users press SW1, the Master switches to Diagnostic Interleave mode to send Read data by identifier (0x22)

On receiving Read data by identifier request, the slave will send back data as implemented in main function.

4)    Whenever users press SW4,  the Master switches to Diagnostic Interleave mode to send Assign Frame Id range. In this example, the Master changed PID 0x22 to 0x27.

After that, the slave will not respond to Master header 0x22 in GPA table anymore, since this PID was successfully changed.

Also please note that for diag table he should use:

diag

{

    FreeFormat {0x09, 0x06, 0x22, 0x00, 0xFF, 0x7F, 0xFF, 0xFF} delay 20.0 ms; /* Users can specify other data here*/

    SlaveResp                          delay 20.0 ms;

}

Instead of

diag

{

   MasterReq                          delay 20.0 ms;

    SlaveResp                          delay 20.0 ms;

}

The Eclipse Plugin GUI would help you to config FreeFormat Master Request data.

Please let us know if this helps you.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,283 Views
deepakchandra
Contributor III

dear sir

also i would like to one thing , when i have send below frame followed by 3c i get reply followed by 7d for assign frame id ,

is this correct.

pastedImage_0.png

now our NAD has been changed is this will same(22) after power off  or o6

0 Kudos
2,284 Views
RadekS
NXP Employee
NXP Employee

Hi deepak,

1. According to LIN Specifications, the Read by Identifier should be as follow:

Read by Identifier request.png

It seems that you made wrong command data.

                The correct command should be (based on data in LDF_example.ldf):  0x09 0x06 0xB2 0x00 0x0F 0x00 0x10 0x00

ALIN_2 {

LIN_protocol = "2.1"; /* Node protocol version */

configured_NAD = 0x9; /* configured NAD of node (1-125) */

initial_NAD = 0x9; /* initial NAD of node (1-125) */

product_id =    0xf,  0x10,    0x2; /* Product id */

response_error = ALIN_2_RsErr; /* Response error signal */

P2_min = 50 ms; /* P2_min */

ST_min = 0 ms; /* ST_min */

N_As_timeout = 1000 ms; /* N_As timeout value */

N_Cr_timeout = 1000 ms; /* N_Cr timeout value */

configurable_frames {

ALIN_2_Stat_Frm;

ALIN_Rq_Frm;

}

2. If the Master want to send Sleep mode command, users can use command:

l_sch_set(LI0, LI0_GOTO_SLEEP_SCHEDULE, 0);

then the Master will send go to sleep command to all slaves, and it also will switch to sleep mode.

In order to wake up, the Master should send l_ifc_wake_up(LI0); and switch schedule table to normal table.

In sleep mode, we have not implemented power save mode yet. It was decided that users application should implement that.

Please let me know whether you have any doubts about MCU power save modes (WAIT/STOP/Pseudo STOP).

3. After successfully changed NAD, the Configured NAD was changed to new NAD that is 0x22. But after reset, then the NAD is restored back to configured NAD in LDF file that is 0x09.

By the way, in the LDF_example, the Configured_NAD for node ALIN_2 is 0x09. but his commands were using NAD 0x06. This is also one possible reason, the slave did not answer.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,283 Views
deepakchandra
Contributor III

Dear sir ,

Thanks for u r answer it was correct and I have tried with 06 because in my LDF I have change it to 06 and it was showing correct ,

Now my next problem is assign frame ID range I am enable to change frame id , I have already post the mail ,please suggest me.

0 Kudos
2,283 Views
deepakchandra
Contributor III

thanks for your reply ,

1.i have already done in my project which u have guide ,actually we are not using any development board we have completed our hardware design and using it,as per our  customer spec read by identifier sid is 0xb2, iam attaching my code in which i have implemented the same which u have guide me ,

but in this code when i have send the frame for identifier  3C 06 06 b2 00 00 0F 00 10 this will be  not read by slave , i have try to read by function ld_get_raw( master_req_dat) ; master_req_dat cannot show the frame data ,also i have read with function ld_receive_message(&master_req_length,master_req_dat); but no result

2.sleep mode i have implemented the sleep mode in our project , but i dont know how    it go to sleep using LIN command 3c 00 ff ff ff ff ff ff ff ,also how to wake up from lin command .

please suggest me ASAP.

0 Kudos
2,283 Views
deepakchandra
Contributor III

we are waiting for your reply

0 Kudos