Wie im Thread http://www.mikrocontroller.net/forum/read-1-149112.html beschrieben hab ich ein EA DOG 16x2 im SPI Mode an einen ATTiny26 folgendermaßen angeschlossen. (Bild im Anhang)
Ich benutze PA.4 bis PA.7 zur Ansteuerung.
Weiter unten in dem Thread is nen Bascom Beispiel Source den ich größtenteils übernommen hab. Hier meine angepasste Version:
Code:'-------------------------------------------------------------------- ' Autor: Robert Mayr '-------------------------------------------------------------------- $prog , &HF1 , , 'Hardware-Einstellungen fuer internen 1 MHz Taktgeber $crystal = 1000000 '1 MHz, Damit auch die Software davon weiss $regfile = "at26def.dat" 'Wir benutzen einen Tiny26 'LCD Command Codes Const Cleardisplay = &H01 Const Returnhome = &H02 '-------------------------------------------------------------------- '******* Konfiguration PortA 4-7 zur LC-Ausgabe mit DOGM162 ******* '-------------------------------------------------------------------- Ddra = &B11110000 'Pin PA4-7 ist Ausgang 'PA4 = SI 'PA5 = CLK 'PA6 = RS 'PA7 = CSB Porta = &B111100000 'PullUp von PA4-7 aktivieren Dim J As Byte Dim Text As String * 16 Dim Ausgabe(16) As Byte At Text Overlay Dim I As Byte '-------------------------------------------------------------------- '********* vor allem anderen, gebe was auf das Display Gosub Lcinit Gosub Intro 'Startbildschirm End 'end program '********* Daten Seriell ausgeben ********** Schiebe: Waitus 30 Reset Porta.7 'CSB auf 0 Shiftout Porta.4 , Porta.5 , J , 1 , 8 , 10 'schiebe 8 bits mit der steigenden Flanke und 10us Delay raus Set Porta.7 'CSB auf 1 Return '-------------------------------------------------------------------- '******* Hier wird die erste Meldung aufs Display gezaubert ********* '-------------------------------------------------------------------- Intro: 'Cls 'clear the LCD display 'Cursor Off J = &H80 : Gosub Schiebe 'select the upper line Text = "1234567890123456" 'display this at the top line Gosub Textaus J = &HC0 : Gosub Schiebe 'select the lower line Text = "abcdefghijklmnop" 'display this at the lower line Gosub Textaus Return '-------------------------------------------------------------------- '********************** Textausgabe auf Display ********************* '-------------------------------------------------------------------- Textaus: Set Porta.6 'RS auf 1 For I = 1 To 16 J = Ausgabe(i) Gosub Schiebe Waitms 200 Next I Reset Porta.6 'RS auf 0 Return '-------------------------------------------------------------------- '********************** Initialisiere LC-Display ******************** '-------------------------------------------------------------------- Lcinit: Waitms 50 Set Porta.5 'CLK=1 Set Porta.7 'CSB auf 1 Reset Porta.6 'RS auf 0 Reset Porta.7 'CSB auf 0 'Initialisiere LCD J = &H38 : Gosub Schiebe '0011 1000 8Bit 2Lines IS[0,1] J = &H39 : Gosub Schiebe '0011 1001 8Bit 2Lines IS[0,1] J = &H1D : Gosub Schiebe '0001 1101 Cursorshift: Screen Right IS[0,1] J = &H7C : Gosub Schiebe '0111 1100 Contrast = 0C -> 12/64 J = &H50 : Gosub Schiebe '0101 0000 Icons off, Booster off, Contrast 00 J = &H6C : Gosub Schiebe '0110 1100 Fon = On, Rab = 4 Waitms 200 J = &H0F : Gosub Schiebe '0000 1111 Display = On, Cursor = On, CursorBlink = On J = &H01 : Gosub Schiebe '0000 0001 Clear Display J = &H06 : Gosub Schiebe '0000 0110 DDRam Increments, no DisplayShift Set Porta.7 'CSB auf 1 Return






Zitieren

Lesezeichen