• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Hercules™ Safety Microcontrollers » Hercules™ Safety Microcontrollers Forum » Lin module
Share
Hercules™ Safety Microcontrollers
  • Forum
  • E2E Wiki
Options
  • Subscribe via RSS

Forums

Lin module

This question is answered
Florian H.
Posted by Florian H.
on Apr 04 2012 10:37 AM
Prodigy105 points

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 

LIN TMS570 MCBTMS570
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Jean-Marc Mifsud
    Posted by Jean-Marc Mifsud
    on Apr 04 2012 14:49 PM
    Genius10470 points

    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,

    Jean-Marc

    Application Engineer


    If my reply answers your question please click on the green button "Verify Answer".

    LIN
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Prathap
    Posted by Prathap
    on Apr 06 2012 12:35 PM
    Expert6465 points

    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

    ~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Florian H.
    Posted by Florian H.
    on Apr 12 2012 09:54 AM
    Prodigy105 points

    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 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Prathap
    Posted by Prathap
    on Apr 13 2012 07:18 AM
    Expert6465 points

    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

    ~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Florian H.
    Posted by Florian H.
    on Apr 13 2012 11:53 AM
    Prodigy105 points

    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 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Prathap
    Posted by Prathap
    on Apr 15 2012 07:43 AM
    Expert6465 points

    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

    ~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Florian H.
    Posted by Florian H.
    on Apr 16 2012 11:35 AM
    Prodigy105 points

    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 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Prathap
    Posted by Prathap
    on Apr 16 2012 12:09 PM
    Verified Answer
    Verified by Florian H.
    Expert6465 points

    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

    ~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Florian H.
    Posted by Florian H.
    on Apr 17 2012 03:37 AM
    Prodigy105 points

    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 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Florian H.
    Posted by Florian H.
    on May 03 2012 00:58 AM
    Prodigy105 points

    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

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Prathap
    Posted by Prathap
    on May 04 2012 12:06 PM
    Expert6465 points

    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.


    ~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Julius Woo
    Posted by Julius Woo
    on Jul 24 2012 12:37 PM
    Prodigy10 points

    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,

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Prathap
    Posted by Prathap
    on Jul 25 2012 01:17 AM
    Expert6465 points

    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

    ~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Amit Chincholi
    Posted by Amit Chincholi
    on Sep 26 2012 05:07 AM
    Prodigy40 points

    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

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Prathap
    Posted by Prathap
    on Sep 26 2012 22:08 PM
    Expert6465 points

    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

    ~~~ If a post answers your question, please mark it with the"Verify Answer" button. ~~~

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
12
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use