Hot!LIN bus Code examples in C

Author
dak_de_gene
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2008/02/26 08:25:21
  • Location: 0
  • Status: offline
2010/11/16 21:27:35 (permalink)
0

LIN bus Code examples in C

Hi,

I have been looking very hard to find a sample code that works for LIN bus communication on the 28 pin Lin demo board kit provided by microchip. Unfortunately none of the application notes i have found on the website seem to work and are too few in number as well. I am using a PIC 18f2525 microcontroller with a EUSART and i need atleast one master and one slave example that i could work with. I would very much appreciate if anyone has cues on the same. 

Thanks
#1

10 Replies Related Threads

    andy_morosta
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2011/02/25 05:35:25
    • Location: 0
    • Status: offline
    Re:LIN bus Code examples in C 2011/02/25 05:37:29 (permalink)
    0
    Hi!

    I'm looking for such a code / Example too!

    It's impossible to find anything on the net or on Maxim.

    Can anybody help?

    Thx
    #2
    clark.leach
    Super Member
    • Total Posts : 361
    • Reward points : 0
    • Joined: 2008/09/17 10:55:43
    • Location: Maine USA
    • Status: offline
    Re:LIN bus Code examples in C 2011/03/23 08:11:17 (permalink)
    0
    AN1009 is about as close as you will get to PIC18 LIN code examples.
    Good luck understanding the undocumented, sparsely commented, totally obfuscated code.


    Aut Viam Inveniam Aut Faciam
    #3
    Tom Veik
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2010/12/14 06:35:29
    • Location: 0
    • Status: offline
    Re:LIN bus Code examples in C 2011/03/23 17:02:56 (permalink)
    0
    I've been told that Microchip is no longer supporting their app notes on LIN.  They are redirecting people to IHR for LIN support.  IHR has LIN demo code that works with Microchip's 28 pin LIN demo board.

    http://www.ihr.de/cms/front_content.php?idart=126
    #4
    clark.leach
    Super Member
    • Total Posts : 361
    • Reward points : 0
    • Joined: 2008/09/17 10:55:43
    • Location: Maine USA
    • Status: offline
    Re:LIN bus Code examples in C 2011/04/12 12:17:56 (permalink)
    0
    For what it's worth - I emailed IHR no less than twice, attempting to find out how to purchase their LIN tools and what the cost would be, and received nothing in return.  I wonder how they sell this stuff when they won't even answer their email.

    Aut Viam Inveniam Aut Faciam
    #5
    Tom Veik
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2010/12/14 06:35:29
    • Location: 0
    • Status: offline
    Re:LIN bus Code examples in C 2011/04/12 19:30:03 (permalink)
    0
    I've had good luck working with IHR so far.  They helped me with an issue I had with their demo program by email.  Haven't purchased their driver tool yet though.
    #6
    suman_n
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2017/09/26 06:51:44
    • Location: 0
    • Status: offline
    Re:LIN bus Code examples in C 2017/10/24 22:52:36 (permalink)
    0
    Tom Veik
    I've had good luck working with IHR so far.  They helped me with an issue I had with their demo program by email.  Haven't purchased their driver tool yet though.

    if you have lin example code please share your code to suman@sloki.in
     
    thanks
    #7
    btbass
    Super Member
    • Total Posts : 332
    • Reward points : 0
    • Joined: 2004/12/10 13:50:32
    • Status: offline
    Re:LIN bus Code examples in C 2017/10/25 04:33:09 (permalink)
    +1 (1)
    Here is simple Lin code to send and receive messages as Master.
    It was written for the Pic16f but as it is C it should be easy to port to the Pic18f.
     
    To use, in your code declare two LINMSG types:
    volatile LINMSG Tx_Msg;
    volatile LINMSG Rx_Msg;
     
    Send message example:
     
    Tx_Msg.ID = 0xC1;
    Tx_Msg.length = 3;
    Tx_Msg.data[0] = 0x00;
    Tx_Msg.data[1] = 0x30;
    SendMessage((LINMSG *)&Tx_Msg);
     
    Send request example:
     
    Rx_Msg.ID = 0xb4;
    Rx_Msg.length = 8;
    SendRequest((LINMSG *)&Rx_Msg);
     
    Add this to your interrupt routine to receive response from slave.
    if(RCIF)
      {
      if(slave_response()){
        Ecu.response_flag = True;
        }
      }
     
    (It is a zip file, had to rename as .txt to upload, rename it to .zip)
    post edited by btbass - 2017/10/26 22:38:26
    #8
    suman_n
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2017/09/26 06:51:44
    • Location: 0
    • Status: offline
    Re:LIN bus Code examples in C 2017/10/25 22:46:55 (permalink)
    0
    btbass
    Here is simple Lin code to send and receive messages as Master.
    It was written for the Pic16f but as it is C it should be easy to port to the Pic18f.
     
    To use, in your code declare two LINMSG types:
    volatile LINMSG Tx_Msg;
    volatile LINMSG Rx_Msg;
     
    Send message example:
     
    Tx_Msg.ID = 0xC1;
    Tx_Msg.length = 3;
    Tx_Msg.data[0] = 0x00;
    Tx_Msg.data[1] = 0x30;
    SendMessage((LINMSG *)&Tx_Msg);
     
    Send request example:
     
    Rx_Msg.ID = 0xb4;
    Rx_Msg.length = 8;
    SendRequest((LINMSG *)&Rx_Msg);
     
    (It is a zip file, had to rename as .txt to upload, rename it to .zip)




    Sir I am using PIC32MX550f256L micro controller can we get LIN driver to this micro controller or we can able to communicate with LIN or we have to use PIC16f or PIC18f only because i seen in PIC16 family having EUSART but PIC32F family having only UART.
     
    Regards,
    Suman N,
    thank you.
    #9
    qhb
    Superb Member
    • Total Posts : 6262
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re:LIN bus Code examples in C 2017/10/25 22:59:47 (permalink)
    +1 (1)
    suman_n
    ...
    Sir I am using PIC32MX550f256L micro controller can we get LIN driver to this micro controller or we can able to communicate with LIN or we have to use PIC16f or PIC18f only because i seen in PIC16 family having EUSART but PIC32F family having only UART.

    LIN uses asynchronous signalling, so it does not matter that the PIC32 is only a UART.
     
    #10
    sunilhalvi
    Starting Member
    • Total Posts : 36
    • Reward points : 0
    • Joined: 2017/02/28 07:12:48
    • Location: Bangalore, Karnataka, India
    • Status: offline
    Re:LIN bus Code examples in C 2017/11/02 04:20:26 (permalink)
    0
    Hi qhb,
    Is there any application note which guides to write LIN drivers for PIC32MX550f256L.
    PIC32MX550f256L's data sheet says it supports LIN1.2, can we use it to build LIN1.3 or higher master.
     
    #11
    Jump to:
    © 2018 APG vNext Trial Version 4.5