This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Lin module

Other Parts Discussed in Thread: TMS570LS20216, HALCOGEN, TMS570LS3137

Hi,

I have a question about the LIN module on the  TMS570LS20216.

I use the KEIL MCBTMS570 board to develop  a communication using LIN module.

I use the tms507.h and some files of example project (Blinky). I have only change the lin configuration as following : 

void linInit(void)
{
linREG2->GCR0=1U; //The module is out of reset

linREG2->GCR1=(0<<7); //Software reset for configuration

/** - Setup Pin function */
linREG2->FUN=(1<<2) //LINTX is transmit pin
|(1<<1) //LINRX is receive pin
|(0<<0); //SCICLK is a general purpose digital I/O pin

/** - Select LIN mode */
linREG2->GCR1 |=(1<<6); //LIN mode is enable

/** - Master or slave mode */
linREG2->GCR1 |=(1<<5); //The node is in master mode

/** - Select the desired frame format */
linREG2->GCR1 |=(0<<11) //Classic checksum is used
|(1<<4) //Two stop bits are used
|(1<<3) //Even parity is used
|(0<<2) //ID field parity verification is disabled
|(0<<1) //This bit isn't effectived in LIN mode
|(0<<0); //ID4 and ID5 aren't used for length control

/** - Setup response length */
linREG2->LENGTH = (8U - 1U); //Length is set to 8 Bytes

/** - Setup LIN compare register */
linREG2->COMP = (0x3 << 9) //The synch delimiter is 4Tbit
|0x7; //The synch break has 7 additional Tbit=>20Tbit

/** - Select multi-buffer mode */
linREG2->GCR1 |=(1<<10); //The multibuffer mode is enable


/** - Setup maximum baud rate prescaler */
// linREG2->MBRSR = 4507U; //0x119B INITIAL VALUE
linREG2->MBRSR = 3600U; //0xE10

/** - Setup baud rate prescaler */
// linREG2->BRSR = 312U; //0x138 INITIAL VALUE
linREG2->BRSR = 3600U; //0xE10

/** - Set the CONT bit */
linREG2->GCR1 |=(1<<17); //When debug mode is entered the LIN continues to operate

/** - Set LOOP BACK */
linREG2->GCR1 |=(0<<16); //Loopback mode is disable


/** - Select the transmit and receiver enable */
linREG2->GCR1 |=(1<<25) //Enable transmit
|(1<<24); //Enable receive

/** - Setup RX and TX reception masks */
linREG2->MASK=(0xFFU<<16U) //Receive ID mask
|(0xFFU); //Transmit ID mask

/** - Setup TX and RX interruption */
linREG2->SETINT |=(1<<8) // Enable TX INT
|(1<<9); // Enable RX INT

/** - Setup TX and RX DMA */
linREG2->SETINT |=(1<<16) // Enable TX DMA
|(1<<17); // Enable RX DMA

/** - Finaly start LIN2 */
linREG2->GCR1 |=(1<<7); //Software out of reset 

}

When I use the function linSendHeader, I can detect this first frame.

Just after calling this function I call the function linSend, but nothing occurs.  I thing I missed something but I don't know what.

I would like to use DMA in order to avoid issue during transmitting but I don't understand how it works.

Please can someone can give me further information about  transmitting.

Thank you very much,

BR 

  • Florian,

    Thanks for posting on our forum.


    I've contacted our LIN expert.
    You should here from him soon.

    Best Regards,

    Jean-Marc

  • Hi

    Please find the attached sample LIN + DMA Code. LIN driver is created out of HALCoGen.

    I used TMS570LS3137x device for sample code, but this can be used for TMS570LS20216 just check the LIN based address and DMA TX request line from data sheet

    7181.LIN_Test.zip.

    Best Regards
    Prathap

  • Prathap,

    I have tested your code, and addresses are the same with TMS570LS20216. I just change the address  for use the LIN2 module.

    It doesn't work.

    One think I can't explain is why the PBE bit is set ? Maybe this bit prevents the UC from sending the data ?In the data sheet they said that is due to a shortage or that RX is @+Vbat. How it is possible with the development board ?

    Thank you,

    Florian 

  • Hi Florian

    Attached is the Same code ported for LIN1 TMS570LS20216 device.0602.LIN_DMA_20SMDK.zip

    Sorry I do not have the development board, but please chake the schematics of the board, LIN2 is connected the FTDI chip which is again used as UART port to talk to PC. All demo softwares use this feature to talk to the board.

    Can you try yhe software on LIN1 in the same board.

    Best Regards
    Prathap

  • Hi Prathap,

    Your code allows to fill RDx registers ? If yes, it works perfectly.

    Otherwise, I can see the signal from LIN1TX  at the oscilloscope ?

    On other thing is strange : I have previously programmed the LIN2 register and then copy the same setting to the LIN1 register. The lin1 bus doesn't work. Do you know why ?

    Thank you for your help,

    Kind Regards,

    Florian 

  • Hi Florian

    LIN module is configured to use TX DMA, LIN generates the LIN DMA TX request when ever the Transmit (TDx) register is empty. 
    DMA is configured to fill the LIN transmit register. LIN is configured to do Digital loop back. Moment LINID is transmitted followed by the data, since loop back is enabled the data is received back.

    So RDx register is not filled by the Software, it is actual data received back. On TDx register is filled by DMA.

    Please check your settings againts the same code I sent.

    Best Regards
    Prathap

  • Hi Prathap,

    Thank you for your reply!!

    In your code, the loop back is disable since the SCIGCR1 register value is 0x03001CE0.

    But one thing I don't inderstand is why I can see the signat at the oscilloscope when it is transmitted ? According to your code, I should be able to see it ?

    I am soory for the request, but I am a newbie with ARM microcontroller.

    Thank you for your help,

    BR,

    Florian 

  • Hi Florian,

    Yes I did not use the Loopback bit in the GCR1 register. Insteadd I used the IODFTCTRL register which has a loop back mode.
    Using IODFTCTRL register you can do either DIgital loop back or Ananlog loopback. I think my code I did Digital loop back hence you do not see the Pin action.
    To monitor the Pin action ( frame) during this loopback mode Please enable Analog Loopback mode. ( linREG->IODFTCTRL = 0x00000A02;).  

    Best Regards
    Prathap

  • Hi Prathap,

    Thank you very much for your help. I have change the value of the IODFTCTRL register and it works perfectly !!

    Best Regards,

    Florian 

  • Hi,

    Can someone has a idea, when I disable the loopback, the data from TDx are not transmitted. Does someone know why ?

    Thank you,

    Florian

  • Hi Florian,

    I think there is issue with your BUS, do you have a transreceiver, Because if Loopback is configured no transreceiver is needed.

    Following are the sequence to be checked

    For Master TX data
    1) The ID-Slave Task byte and Mask must be programmed ( Assuming HGENCTRL = 1)
    2)  LIN ID to be be transmitted must be placed in LIN
    3) If the LIN transeiver and the Bus is free LIN ID is tranmitted.
    4) Master will receive the ID ( check "Recived ID field" ) and
    5) If there is a TX match the data written to TDx register will be transmitted out.

    Note:
    -- LIN is a Protocol in which master receivs the ID which it tranmitts and based on the TX or RX match either it transmitts or receives. For this to happen either you should have a proper transreceiver / bus or for debug purpose Loopback.


  • Hi Prathap,

    I am trying to see the sample LIN + DMA Code  above. I have TMS570LS3137 HDK kit as well. After loading the project, I am having issues with endianness.

    Would you be able to tell me how to flash the code with CCS v5?

    Thank you,

  • Hi Julius

    My suggession if you want to use example for TMS570LS3137 would be

    1) Create an empty project for TMS570LS3137 in CCS5
    2) Add the files in the exapmle which I upload in earlier thread.
    3) Compile and download using ccs5

    Regards
    Prathap

  • Hi Prathap,

    I have a query , I have set up one master node and slave node for LIN. I am able to send the header but, receiver is not detecting it. When I configure master in loop back mode I am able to see the ID is being received back.

    All the settings are same for Master and slave except some bits in registers which define master and slave.

    I am not using your uploaded code, I am using some other code in which I am not initializing any DMA.

    Thanks in advance.

    Rgds,

    Amit

  • Hi Amit,

    Questions

    1) What's the Slave, is it again an other TMS / RM Micro.

    2) How do you conect Master and Slave? Is it through LIN traseivers or u are trying to connect directly? U need to make sure atleast all lines arewired AND if connecting directly..

    3) If u can Send your code snippet both master and slave, it would be easy to comment

    -Prathap

  • Hi Prathap,

    1) We are using 2 Similar TMS570LSxxx16ZWT micro boards with Lin Transceiver TJA1020T.
    One board is configured as Master and other one is configured as Slave.
    The Master will be sending the header 0x16 every 100ms and slave has to respond to it with some data.
    We are able to send header from Master board and able to see it on scope. But the slave is not detecting this header. The baud rate configured is 9600.
    It is not setting any flag or updating the recieved ID. The issue which I am facing is with slave code not able to detect the header send by the Master board.

    2) The slave is configured to adapt to the baud rate of the master although the settings for baud rate are same in both micros.

    3) Lin pin from two transceiver are connected together along with the ground.

    I have attached the files related to LIN.

    1. main.c
    2. SerialIO.c ->Lin related funtions
    3. startupPSFC61.c - Start up code

    and header files related to it.

    3817.Master.zip

    5047.Slave.zip

    Expecting your reply at the earliest

    Amit

  • Amit

    I removed my previous response sine I made a wrong suggestion. 

    I tried replicating your settings and was able to receive, one request can you send the snap shot of Lin register values both Master and slave after completing Init.

    - Prathap

  • Hi Florian,

    I am facing the same issue. Once I took out loopback, no data is transmitted from TX. How did you solve the problem??

    Thanks a lot!