
(2) Ref. Programming
'---------------------------------------------------------------------------------
'It is an OSD2002-2 pattern program and shows A,B,C….on module.
'Here use BASCOM-AVR compile.
'---------------------------------------------------------------------------------
' Project name : 20x2 character module
' file name : demo2002.bas
' MCU : AVR AT90S8515
' Xtal : 8MHz
' Panel I/F : RS, RW, Enable, BTV
' Writer : Cheng-Nan Yeh
' Date : Dec.26, 2002 rev:A
'-----------------------------------------------
' DB0=PA0: DB1=PA1: DB2=PA2: DB3=PA3
' DB4=PA4: DB5=PA5: DB6=PA6: DB7=PA7
' RS=PB2: RW=PB1: Enable=PB0
'-----------------------------------------------
'-------------initial setting
$regfile = "8515DEF.DAT"
Config Porta = Output
Config Portb = Output
Dim J As Integer , Cara As Byte , I As Byte
Dim Command_diable As Byte, Command_enable As Byte
Dim Command_write_data As Byte , Command_clear_display As Byte
Dim Command_move_right As Byte , Command_display_on As Byte
Dim Command_line2_char5x7 As Byte , Command_ddram_&H00 As Byte
Dim Command_ddram_&H40 As Byte , Write_char As Byte
'---------
Command_diable = &H00
Command_enable = &H01
Command_clear_display = &H01
Command_move_right = &H1D
Command_display_on = &H0C
Command_line2_char5x7 = &H38
Command_ddram_&H00 = &H80
Command_ddram_&H40 = &HC0
Command_write_data = &H05
Write_char = &H40
'---------
C = 1
I = 0
'-------------clear module display and cursor back home
Portb = Command_enable 'RS=0, RW=0, Enable=1
Porta = Command_clear_display
Waitus 500 'wait 500uS for MCU internal delay time
Portb = Command_diable 'You need to set PB0=0 after PB0=1 for MCU.
'-------------setting S/C, R/L, I/D, S
Portb = Command_enable
Porta = Command_move_right 'S/C=1 ,R/L=1 ,I/D=0, S=1
Waitus 500
Portb = Command_diable
'--------------display on / off
Portb = Command_enable
Porta = Command_display_on 'D=1, C=0, B=0
Waitus 500
Portb = Command_diable
'--------------setting 5x7 Char. 2-Line
Portb = Command_enable
Porta = Command_line2_char5x7 'DL=1, N=1, F=0
Waitus 500
Portb = Command_diable