Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Lin-bus

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions
View previous topic :: View next topic  
Author Message
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Sat Apr 18, 2015 10:00 am    Post subject: Lin-bus Reply with quote

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(Cool 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
View user's profile
PeterM

Bascom Member



Joined: 09 Jun 2008
Posts: 118

australia.gif
PostPosted: Mon Apr 20, 2015 10:17 am    Post subject: Reply with quote

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
View user's profile
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Mon Apr 20, 2015 12:15 pm    Post subject: Reply with quote

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
View user's profile
PeterM

Bascom Member



Joined: 09 Jun 2008
Posts: 118

australia.gif
PostPosted: Mon Apr 20, 2015 12:59 pm    Post subject: Reply with quote

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
View user's profile
PeterM

Bascom Member



Joined: 09 Jun 2008
Posts: 118

australia.gif
PostPosted: Tue Apr 21, 2015 12:02 pm    Post subject: Reply with quote

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
View user's profile
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Thu Apr 23, 2015 10:41 pm    Post subject: Reply with quote

Thank you Peter. I manage to addapt your rutine's with small change's to my need. Very Happy
Back to top
View user's profile
PeterM

Bascom Member



Joined: 09 Jun 2008
Posts: 118

australia.gif
PostPosted: Fri Apr 24, 2015 7:03 am    Post subject: Reply with quote

Ghitab

Maybe post a sample incase others are interested in experimenting with LIN?

_________________
Peter
Back to top
View user's profile
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Fri Apr 24, 2015 8:20 am    Post subject: Reply with quote

Here it is. Very Happy
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum