Route LIN to SCI for s12zvl

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

Route LIN to SCI for s12zvl

2,424 Views
charudattaingal
Contributor IV

Dear Team,

want to use Lin pin of s12zvl as a SCI, not getting expected result code given bellow,

is there need to match baud rate of LIN  to SCI ?

is there need to set SCI as single wire mode ?

2A Diagnostic service  is not supported by LIN protocol,to get this service I need to use SCI

Is it possible to transmit  SCI frame  through LIN Pin ? I don't want to change H/w Pin Connection for one service

Is it LIN physical layer permit this type of implementation ?

 

LP0CR = LP0CR_LPPUE_MASK + LP0CR_LPWUE_MASK + LP0CR_LPE_MASK; /* LIN enable, LIN wakeup enable, LIN pull-up enable */

  MODRR0 = 0x00; /* LIN phy routed to SCI */

SCI0BD = 0x0D05;  //  SCI Baud Rate Register

SCI0CR1 = 0x00;

SCI0CR2 = 0x2C;

getting received interrupt but SCI buffer is empty.

 

interrupt VectorNumber_Vsci0 void SCI0_Isr(void)

{

 

     unsigned char scisr1;

     scisr1 = SCI0SR1;                          // save status register actual status

  

 

    //if receiver interrupt is enabled and corresponding interrupt flag is set

     if((SCI0CR2 & SCI0CR2_RIE_MASK) && ((scisr1 & (SCI0SR1_OR_MASK | SCI0SR1_RDRF_MASK))))

      {

        if(scisr1 & SCI0SR1_OR_MASK)            // if overrun error do nothing/something

          {

            (void)SCI0DRL;                            // clear interrupt flag

         

          }

        else

          {

            //Read data

    

            sc0_data_in = SCI0DRL;             // read received character + clear interrupt flag

            //---------------

            //Simple echo.

            while(!SCI0SR1_TDRE){};            //wait for transmit data register empty flag

            SCI0DRL = sc0_data_in;             //Echo

            //---------------

            //Receive data and store it into buffer

            buffer[pointer_to_buffer] = sc0_data_in;

            pointer_to_buffer++;

            if (pointer_to_buffer >= SIZE_OF_PACKETrx)

            {

                pointer_to_buffer = 0;

              

                //do something with data in buffer

                //or set flag and do something in main program

                //buffer_full = 1;  //flag for main program

            }

}

 

Thanks & Regards,

Charudatta

Labels (1)
4 Replies

1,780 Views
RadekS
NXP Employee
NXP Employee

Hi Charudatta,

is there need to match baud rate of LIN  to SCI ?

It is not necessary, but it is recommended. I suppose that your bus clock is 32MHz and baud rate 9600 bps. Correct?

In that case, you should set Slew-Rate Bits LPSLR[1:0] = 0b01 Slow Slew Rate (optimized for 10.4 kbit/s).

LP0SLRM=0x01;

is there need to set SCI as single wire mode ?

No, SCI is connected to LIN PHY by RX and TX signal. LIN PHY is responsible for transfer these lines to “one wire” LIN bus. So, LIN PHY will manage that every byte which you sent, you will also receive.

2A Diagnostic service is not supported by LIN protocol, to get this service I need to use SCI

You mean SID 0x2A?

I am slightly confused. SCI has to be used anyway. SCI module is responsible for transmitting and receiving LIN frames. For what else you use SCI and LIN PHY modules?


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

1,780 Views
charudattaingal
Contributor IV

Hi RadekS,

Thanks for your quick response, I am using LIN for diagnostic service.

Is there any way to implement SID 0x2A.service using LIN?

For example: I will request the SID 0x2A. service on LIN pin ,It is internally routed to SCI,then SCI will transmit data on LIN pin.

Or I need to use dedicated SCI RX and TX pins for SID 0x2A.service.

Have a great day,

Charudatta

0 Kudos

1,780 Views
RadekS
NXP Employee
NXP Employee

Hi Charudatta,

SCI module and LIN PHY is enough for LIN communication from the hardware point of view. You will just need external pull-up and diode for master node.

From the software point of view, you will need implement LIN driver and implement SID 0x2A probably as Diagnostic Class 3 service.

  1. LIN stack contains Eclipse tool for generating NPF files. You should add this service to NPF file. For example: user = 0x2A;
  2. Then generate lin_cfg files. You should see that flag is generated for SID user { DIAGSRV_USER_ORDER} .
  3. In Master’s application: You can send request data similarly in the case of sending Read Data by Identifier or Assign Frame ID Range
  4. In Slave’s application: You can detect whether slave has received Master request with SID user: Do similar as in the case of processing Read Data by Identifier

  if(diag_get_flag( DIAGSRV_USER_ORDER)

{

  l_u16 req_len = 0;

  l_u8 req_data[10];

diag_clear_flag(DIAGSRV_USER_ORDER);

  /* Process data */

ld_receive_message(&req_len, req_data);

  req_data[0] += 0x40; // RSID = SID + 0x40

/* Put your code to perform necessary action here */

/* Send response */

  ld_send_message(10, req_data);

}


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

1,625 Views
veeraju
Contributor I

Hi RadekS,

i am using S12ZVL chip, i am thinking that, I need to add frames in the schedule table definition(LDF file) for 3c and 3d frame usage for service 0x22. if i am wrong means please correct me.

i got struck in the selection of the item type. which item type i need to select for the SID 0x22? for reference i shared snapshot

 in item type there is the option called Frame. and there is a dropdown for selection for frames MasterReq & SlaveRes. if i use this frames where i need to update the data for this frame?

Thanks & regards,

Veeraju V Hallikeri

0 Kudos