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
Best regards,
Application Engineer
If my reply answers your question please click on the green button "Verify Answer".
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 RegardsPrathap
~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~
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.zipSorry 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.
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,
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.
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.
BR,
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;).
Thank you very much for your help. I have change the value of the IODFTCTRL register and it works perfectly !!
Can someone has a idea, when I disable the loopback, the data from TDx are not transmitted. Does someone know why ?
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 data1) The ID-Slave Task byte and Mask must be programmed ( Assuming HGENCTRL = 1)2) LIN ID to be be transmitted must be placed in LIN3) 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.
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?
Hi Julius
My suggession if you want to use example for TMS570LS3137 would be
1) Create an empty project for TMS570LS3137 in CCS52) Add the files in the exapmle which I upload in earlier thread.3) Compile and download using ccs5RegardsPrathap
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