View previous topic :: View next topic |
Author |
Message |
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Sat Apr 18, 2015 10:00 am Post subject: Lin-bus |
|
|
Hi. I'm playing with a vw steering wheel based on lin bus(2.0). I use an atmega32m1 and tja 1020 as transceiver. I manage to send id and steering wheel respond, but i can't read or i don't understend from datasheet how is LINDAT loaded. I have no error in lin error flag register. Any help is apreciated.
Thank you.
$regfile = "m32m1.dat"
$crystal = 16000000
$hwstack = 100
$swstack = 150
$framesize = 400
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.7 , Db5 = Portb.4 , Db6 = Portb.3 , Db7 = Portc.6 , E = Portb.5 , Rs = Portb.6
Cursor Off
Cls
Config Portc.1 = Output 'enable tja transceiver
Set Portc.1
Lcd "test lin"
Wait 1
Cls
Dim A( As Byte
Dim B As Byte
Linbtr = 160 'disable resync,
Linbrrl = 25 'baudrate 19200
Linbrrh = 0
Lincr = &B00001000 'rx header
Lindlr = &B00011000 '1 tx byte, 8 rx byte
Linenir = &B00000001 'receive interupt enable
Linsel = &B00000000 'autoincremet fifo
Do
Locate 1 , 1
Lcd A(2) ; " " ; Lrxok ; " " ; Linsir.4
Locate 2 , 1
Lcd Lincr ; " " ; Linsir ; " " ; Linerr ;
Waitms 10
Linidr = &B10001110 'id 8E to read button's
'Linidr = &B10111010 'id BA
Lincr = &B00001001 'header + id
For B = 1 To 8
A(b) = Lindat
Next
Loop
//---------------------------------
00 55 8E from master,
F4 00 FF F0 60 00 30 00 FA answer from slave,
(BASCOM-AVR version : 2.0.7.7 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
PeterM
Joined: 09 Jun 2008 Posts: 118
|
Posted: Mon Apr 20, 2015 10:17 am Post subject: |
|
|
Ghitab
Bascom supports LIN/Uart routines, see attiny167.bas sample from the SAMPLES folder.
I am not sure if I missed something in the Datasheet (I use the M32M1 myself)
but the TX output pin you are using is PORTC.1 , the LIN TX and RX lines are
PORTD.3 (RX Line) and PORTD.4 (TX Line). _________________ Peter |
|
Back to top |
|
|
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Mon Apr 20, 2015 12:15 pm Post subject: |
|
|
Hi. thank's for answer. My attiny167.bas has only a uart example, can you please share your version that has lin example?
Portc.1 I use only for "nslp" pin of tja1020 controller, txlin and rxdlin are linked to pd3 and pd4 of atmega. |
|
Back to top |
|
|
PeterM
Joined: 09 Jun 2008 Posts: 118
|
Posted: Mon Apr 20, 2015 12:59 pm Post subject: |
|
|
Ghitab
Sorry I may have missunderstood, I assumed on a LIN bus you talk to it the same as a UART.
Typically a UART/RS232 won't allow another Node to be connected on the same wire but LIN allows you to
connect to multiple nodes on the same wiring. _________________ Peter |
|
Back to top |
|
|
PeterM
Joined: 09 Jun 2008 Posts: 118
|
Posted: Tue Apr 21, 2015 12:02 pm Post subject: |
|
|
Ghitab
Here are some LIN/UART routines, I wreckon with some minor register changes
it should work as LIN or at least guide you. _________________ Peter |
|
Back to top |
|
|
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Thu Apr 23, 2015 10:41 pm Post subject: |
|
|
Thank you Peter. I manage to addapt your rutine's with small change's to my need. |
|
Back to top |
|
|
PeterM
Joined: 09 Jun 2008 Posts: 118
|
Posted: Fri Apr 24, 2015 7:03 am Post subject: |
|
|
Ghitab
Maybe post a sample incase others are interested in experimenting with LIN? _________________ Peter |
|
Back to top |
|
|
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Fri Apr 24, 2015 8:20 am Post subject: |
|
|
Here it is. |
|
Back to top |
|
|
|