(c) Simon Fraser University, School of Engineering Science
Using a Motorola M68HC12 microcontroller, our team developed a stopwatch in assembly language. It was able to measure time with 1/100 sec accuracy, and display on LCD panel. The project was successful, except debounce issue. We needed a little more memory to implement them on the chip. The following code is a portion of LDC library we have written.
; Subroutine to read from LCD register 0 (Busy flag and address counter).
; The value read is returned in reg A.
LcdR0Read:
bclr PORTB,LcdRS_DnI | LcdE
bset PORTB,LcdRnW
LcdRead:
bset PORTB,LcdE
nop ; data output 160 ns after rising edge of E
ldaa PORTA
bclr PORTB,LcdE
rts
; Subroutine which waits for the LCD to stop being busy.
; Regs Mod: CCR (A modified by LcdR0Read)
WaitDone:
bsr LcdR0Read
bita #LcdBusy
bne WaitDone
rts
; Subroutine to perform an instruction. It waits for the LCD to stop
; being busy before writing the instruction.
; Regs Mod: A, CCR (A modified by nested subroutine calls)
LcdDoInst:
bsr WaitDone
; Subroutine to write an instruction to the LCD.
; Regs Mod: CCR
LcdInstWrite:
bclr PORTB,LcdRnW | LcdRS_DnI | LcdE
bra LcdWrite
댓글 없음:
댓글 쓰기