LCDInfo.com http://forum.lcdinfo.com/ |
|
lcd initialization in asm http://forum.lcdinfo.com/viewtopic.php?f=9&t=1537 |
Page 1 of 1 |
Author: | wimpep [ Fri Apr 07, 2006 10:11 ] |
Post subject: | lcd initialization in asm |
hello I am using the powertip pc1602-H. I want to program this lcd whit a atmega uC in asm. I thryed this code: Code: ;wim peperkamp .include "m168def.inc" ; definitie vab de stuurlijn .equ E = PinC5 .equ RW = PinC4 .equ RS = PinC3 .equ BF = PinB7 ; lcd instructies .equ clear_LCD = 0b00000001 .equ home_LCD = 0b00000010 .equ set_LCD = 0b00111000 .equ LCD_on = 0b00001110 .equ entry_mode = 0b00000110 ; definitie var .def buffer = r16 ;data van naar lcd .def temp = r18 .ORG 0x0000 rjmp main ;**************subroutine unit initialiseer poort c in plaats van d********* init: ldi temp, 0b11111111 ;poortc als uitgang out DDRC, temp cbi PORTC, E cbi PORTC, RS cbi PORTC, RW ret ;************************ routine voor gereed test lcd********************** busy_flag: ldi temp, 0b00000000 ;poortb op ingang out DDRB, temp cbi PORTC, RS ;intructie wordt verzonden sbi PORTC, RW ;LCD in schrijfmodus sbi PORTC, E nop nop nop nop sbic PINB, BF ;lcd gereed? rjmp busy_flag ;nee, herhaal cbi PORTC, E ;lcd uit ret ;lcd gereed ;************************zend data vanuit register buffer naar lcd*********** write_data: rcall busy_flag ;lcd gereed? ldi temp, 0b11111111;Poortb is uitgang out DDRB, temp sbi PORTc, RS ;data wordt verzonden cbi PORTc, RW ;LCD in schrijf modus sbi PORTc, E ;activeer lcd out PORTB, buffer ;verzend data cbi PORTc, E ;lcd uit ret ;********************routine zend instructies vanbuit buffer***************** write_instr: rcall busy_flag ;lcd gereed? ldi temp, 0b11111111;rb is uitgang out DDRB, temp cbi PORTC, RS ;instructie wordt verzonden cbi PORTC, RW ;lcd in schrijfmodus sbi PORTC, E ;activeer lcd out PORTB, buffer ;verzend instructie cbi PORTC, E ;lcd uit ret ;********************hoofdprogramma schrijft shit op eerste en tweede regle lcd main: ldi temp, (1<<CLKPCE) sts CLKPR, temp CLR temp sts CLKPR, temp rcall init ;port c initialiseren ldi buffer, set_LCD ;stel lcd functie in rcall write_instr ldi buffer, LCD_on ;schakel lcd uit rcall write_instr ldi buffer, clear_lcd ;wis display rcall write_instr ldi buffer, entry_mode ;invoer modus rcall write_instr ;****************schrijf data op eerste regel******************* ldi buffer,0x93 rcall write_data ldi buffer,0x24 rcall write_data ldi buffer,0x36 rcall write_data ldi buffer,0x97 rcall write_data ;***************schrijf data op tweede regel********************** ldi buffer, 0b11000000 ;zet op tweede regel rcall write_instr ldi buffer, 0x36 rcall write_data ldi buffer, 0x84 rcall write_data ldi buffer, 0x12 rcall write_data ldi buffer, 0x31 rcall write_data loop: rjmp loop This code has no effect on my lcd. This is the first time that I want to program a Lcd. I think that there is something wrong with the initialization. But what? I hope any one can help me. meanwhile thx |
Page 1 of 1 | All times are UTC + 2 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |