.include "c:\avrtools\appnotes\2313def.inc" ;------ Commands --------------------------------------------- .equ cmdClearDisplay = 0x80 ;To distingish these commands from .equ cmdGotoLine1 = 0x81 ;standard ASCII, the MSB is set. .equ cmdGotoLine2 = 0x82 .equ cmdGotoLine3 = 0x83 .equ cmdGotoLine4 = 0x84 .equ cmdCursorLeft = 0x85 .equ cmdCursorRight = 0x86 .equ cmdDisplayOff = 0x87 .equ cmdDisplayOn = 0x88 .equ cmdCursorOn = 0x89 .equ cmdCursorOff = 0x8A .equ cmdBlinkOn = 0x8B .equ cmdBlinkOff = 0x8C .equ cmdWakeup = 0x8D ;------ PortB Defines ---------------------------------------- .equ db0 = 0 ;display data 0 .equ db1 = 1 ;display data 1 .equ db2 = 2 ;display data 2 .equ db3 = 3 ;display data 3 .equ db4 = 4 ;display data 4 .equ db5 = 5 ;display data 5 .equ db6 = 6 ;display data 6 .equ db7 = 7 ;display data 7 ;------ PortD Defines ---------------------------------------- .equ rs = 2 ;register select .equ rw = 3 ;read/write select .equ ce = 4 ;display enable ;------ Macros for Port control ----------------------------- .macro CE_HI sbi portd,ce .endm .macro CE_LOW cbi portd,ce .endm .macro RS_HI sbi portd,RS .endm .macro RS_LOW cbi portd,RS .endm .macro RW_HI sbi portd,RW .endm .macro RW_LOW cbi portd,RW .endm ;------ Display Constants ----------------------------------- .equ c_Clr = 0x01 ;clear display .equ c_CursorLeft = 0x10 ;move cursor left .equ c_CursorRight = 0x14 ;move cursor right .equ c_Goto = 0x80 ;data ram control .equ c_Line2 = 0x40 ;start address of line 2 .equ c_Line3 = 0x14 ;start address of line 3 .equ c_Line4 = 0x54 ;start address of line 4 .equ f_Set = 0x30 ;Function Commands .equ f_1line = 0x00 ;1 line mode .equ f_2line = 0x08 ;2 line mode .equ f_8font = 0x00 ;5x8 font .equ f_11font = 0x04 ;5x11 font .equ d_Set = 0x08 ;Display Control .equ d_DisplayOn = 0x04 ;Display on .equ d_DisplayOff = 0x00 ;Display off .equ d_CursorOn = 0x02 ;Cursor on .equ d_CursorOff = 0x00 ;Cursor off .equ d_BlinkOn = 0x01 ;Blink on .equ d_BlinkOff = 0x00 ;Blink off .equ e_Set = 0x04 ;Entry mode control .equ e_CursorRight = 0x02 ;cursor moves right .equ e_CursorLeft = 0x00 ;cursor moves left .equ e_NoShift = 0x00 ;cursor doesn't shift .equ e_Shift = 0x01 ;cursor shifts ;------ Flag Bits --------------------------------------- .equ Tick = 0 ;Timer Tick bit ;------ Register Defines -------------------------------- .def lpmr0 = r0 ;used with lpm instruction .def ISRtimer = r1 ;timer ISR .def ISRUart = r2 ;uart rcx ISR .def temp = r3 ;temp register used in uart ISR .def Acc = r16 ;accumulator .def Flags = r17 ;Flag bits .def MyLoop = r18 ;loop counter .def Command = r19 ;command from uart .def Head = r26 ;X register is head pointer .def Tail = r28 ;Y register is tail pointer ;------ Memory Defines ---------------------------------- .equ Buffer = 0x60 ;start of receiver buffer .equ BufEnd = 0xa0 ;end of receiver buffer ;------ Code Start -------------------------------------- .cseg ;start code segment .org 0 rjmp Start ;reset vector reti ;irq0 reti ;irq1 reti ;timer1 capture rjmp Timer ;timer1 compare reti ;timer1 overflow reti ;timer0 overflow rjmp uartrx ;uart receive reti ;udr empty reti ;tx complete reti ;analog compare ;**************************************************************** ; Timer - Timer Interrupt Service Routine * ; Entry occurs every 1ms * ;**************************************************************** Timer: in ISRtimer,sreg ;save status register sbr Flags,1<