'******************************************* ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ';; LCD-Routinen für M50530 ;; ';; ======================= ;; ';; ;; ';; Titel : 4 Bit LCD M50530 ;; ';; Autor : Arno Schweißinger ;; ';; Datum : 28.01.2007 ;; ';; MC : AtMega 8515 1MHz ;; ';; Stromversorgung: MC 5V; LCD 5V & 8,2V ;; ';; ;; ';; 4bit-Interface M50530 ;; ';; ;; ';; DB4: PC0 ;; ';; DB5: PC1 ;; ';; DB6: PC2 ;; ';; DB7: PC3 ;; ';; OC1: PC4 ;; ';; OC2: PC5 ;; ';; EX: PC6 ;; ';; ;; ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; '***************************************** $regfile = "m8515.dat" $crystal = 1000000 'CPU 1MHz Declare Sub Lcd_m50530_init() 'declare the SUB program Declare Sub Lcd_m50530_chr(ch As Byte) Declare Sub Lcd_m50530_command(command As Byte) Declare Sub Lcd_m50530_gotoxy(lcd_x As Byte , Lcd_y As Byte) Declare Sub Lcd_m50530_clear() Declare Sub Lcd_m50530_enable Lcd_m50530 Alias Portc Config Lcd_m50530 = Output _oc1 Alias 4 _oc2 Alias 5 _ex Alias 6 Dim I As Byte ' Zählschleife Dim Lcd_temp As Byte ' Temp im Unterprogramm Dim Lcd_parameter As Byte ' wird an LCD gesendet Dim _x As Byte ' Cursor x Position Dim _y As Byte ' Cursor y Position '------------------------- ' Begin Hauptprogramm '------------------------- Call Lcd_m50530_init _x = 10 : _y = 7 Call Lcd_m50530_gotoxy(_x , _y) For I = 33 To 48 Call Lcd_m50530_chr(i) Next I Do Toggle Portb.0 ' Takt für Spannungskaskade Loop End ' ende Hauptprogramm '------------------------- ' End Hauptprogramm '------------------------- '------------------------------------------------------------------------------- Sub Lcd_m50530_init Lcd_parameter = $d8 'set function mode (SF) 0b11011000 Call Lcd_m50530_command(lcd_parameter) '4bit-Modus einstellen 11 -4/8bit-FONT-2xDUTY-2xRAM Lcd_parameter = $50 'set entry mode (SE) 0b01010000 Call Lcd_m50530_command(lcd_parameter) 'Cursor selbst setzen Lcd_parameter = $33 'set display mode (SD) 0b00110011 Call Lcd_m50530_command(lcd_parameter) 'Display ein, Cursor nicht anzeigen Call Lcd_m50530_clear End Sub '------------------------------------------------------------------------------- Sub Lcd_m50530_chr(ch As Byte) Lcd_temp = Ch Shift Lcd_temp , Right , 4 Set Lcd_temp._oc2 Lcd_m50530 = Lcd_temp Call Lcd_m50530_enable Lcd_temp = Ch And $0f Set Lcd_temp._oc2 Lcd_m50530 = Lcd_temp Call Lcd_m50530_enable Waitus 20 End Sub '------------------------------------------------------------------------------- Sub Lcd_m50530_command(command As Byte) Lcd_temp = Command Shift Lcd_temp , Right , 4 Reset Lcd_temp._oc1 Reset Lcd_temp._oc2 Lcd_m50530 = Lcd_temp Call Lcd_m50530_enable Lcd_temp = Command And $0f Reset Lcd_temp._oc1 Reset Lcd_temp._oc2 Lcd_m50530 = Lcd_temp Call Lcd_m50530_enable Waitus 20 End Sub '------------------------------------------------------------------------------- Sub Lcd_m50530_gotoxy(lcd_x As Byte , Lcd_y As Byte) Select Case Lcd_y Case 1 : Lcd_parameter = $00 Case 2 : Lcd_parameter = $40 Case 3 : Lcd_parameter = $80 Case 4 : Lcd_parameter = $c0 Case 5 : Lcd_parameter = $18 Case 6 : Lcd_parameter = $58 Case 7 : Lcd_parameter = $98 Case 8 : Lcd_parameter = $d8 Case Else : Lcd_parameter = $00 End Select Lcd_parameter = Lcd_parameter + Lcd_x Decr Lcd_parameter Lcd_temp = Lcd_parameter Shift Lcd_temp , Right , 4 Set Lcd_temp._oc1 Set Lcd_temp._oc2 Lcd_m50530 = Lcd_temp Call Lcd_m50530_enable Lcd_temp = Lcd_parameter And $0f Set Lcd_temp._oc1 Set Lcd_temp._oc2 Lcd_m50530 = Lcd_temp Call Lcd_m50530_enable Waitus 20 End Sub '------------------------------------------------------------------------------- Sub Lcd_m50530_clear Lcd_parameter = $01 ' 0b00000001 Display löschen Call Lcd_m50530_command(lcd_parameter) Waitms 2 End Sub '------------------------------------------------------------------------------- Sub Lcd_m50530_enable Set Lcd_m50530._ex Waitus 1 Reset Lcd_m50530._ex End Sub ';----------------------------------- Ende Dispay ----------------------------------------