; ; hello7.lcd.asm ; Neil Gershenfeld CBA MIT 11/12/05 ; .include "tn13def.inc" .def temp = R17 ; temporary storage .def temp1 = R18 ; temporary storage .def temp2 = R19 ; temporary storage .def temp3 = R20 ; temporary storage .equ E = PA3 ; mapping the LCD pins to the AVR pins .equ RS = PA1 .equ DB7 = PA7 .equ DB6 = PA6 .equ DB5 = PA5 .equ DB4 = PA4 .cseg .org 0 rjmp reset .equ delay_time = 100 delay: ldi temp3, delay_time _delay1: ldi temp2, delay_time _delay2: ldi temp1, delay_time _delay3: dec temp1 brne _delay3 dec temp2 brne _delay2 dec temp3 brne _delay1 ret lcd_tx: out PORTA, temp sbi PORTA, E nop nop nop nop nop nop nop cbi PORTA, E rcall delay ret init_lcd: rcall delay ; hold off for a bit ;; send the initialization sequence ldi temp, ( 1 << DB5 ) + ( 1 << DB4 ) rcall lcd_tx rcall lcd_tx rcall lcd_tx ;; function set command - 4-bit interface ldi temp, ( 1 << DB5 ) rcall lcd_tx ;; function set - two lines and 5x7 font ldi temp, ( 1 << DB5 ) rcall lcd_tx ldi temp, ( 1 << DB7 ) rcall lcd_tx ;; display on/off clr temp rcall lcd_tx ldi temp, ( 1 << DB7 ) + ( 1 << DB6 ) + ( 1 << DB5 ) rcall lcd_tx ;; entry mode set clr temp rcall lcd_tx ldi temp, ( 1 << DB6 ) + ( 1 << DB5 ) rcall lcd_tx ret reset: ldi temp, 0xFF ; maximum RC clock out OSCCAL, temp ldi temp, 0xDF out SP, temp ; set the stack pointer to top of SRAM ldi temp, 0xFF ; make all of PORTA be outputs (for the LCD) out DDRA, temp rcall init_lcd ; initialise the LCD ;; go to the zero position ldi temp, ( 1 << DB7 ) rcall lcd_tx clr temp rcall lcd_tx ;; transmit a character (H) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB7 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (E) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB6 ) + ( 1 << DB4 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (L) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB7 ) + ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (L) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB7 ) + ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (O) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB7 ) + ( 1 << DB6 ) + ( 1 << DB5 ) + ( 1 << DB4 ) + ( 1 << RS ) rcall lcd_tx ;; move to the second line ldi temp, ( 1 << DB7 ) + ( 1 << DB6 ) rcall lcd_tx clr temp rcall lcd_tx ;; transmit a character (W) ldi temp, ( 1 << DB6 ) + ( 1 << DB4 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB6 ) + ( 1 << DB5 ) + ( 1 << DB4 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (O) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB7 ) + ( 1 << DB6 ) + ( 1 << DB5 ) + ( 1 << DB4 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (R) ldi temp, ( 1 << DB6 ) + ( 1 << DB4 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB5 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (L) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB7 ) + ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ;; transmit a character (D) ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx ldi temp, ( 1 << DB6 ) + ( 1 << RS ) rcall lcd_tx main: rjmp main