The portion of code related to the LCD locate is as follows (you'll see all this better in Courier or any monospaced font) movlw H'40' call locate ; "Locate 40" Then, in the subroutines section, is the 'locate' subroutine: (Sorry for the spanish comments. If you need, I'll try to translate them...). The full program code is now 'slightly' long, so I put here only the code related to the LCD. What most bother me is that this code works OK with all addresses but '00' and '40'... As you can see, the 'locate' subroutine only sets the 7 bit of W, where the DDRAM address is, and then goes on the subroutine 'princmd'. This one clears the pin 'lcd_rs', to tell the LCD that a command is to be performed, and jumps to the 'envlcd' routine. 'envlcd' sends both the high and the low nibble of W (temporary saved in 'aux') to 'lcdbus', the port in wich the 4 LCD data pins are connected. This port is used to other things as well, so I need to preserve the low nibble of the port. The definitions used in this code portion are: ; Definiciones para el LCD #define lcd_e PORTE,2 ; "Enable" del LCD #define lcd_rs PORTE,1 ; "Register Select" del LCD #define lcdbus PORTD ; El bus del LCD (entrada/salida) #define lcdmasc B'11110000'; M‡scara para preservar los bits ; de lcdbus que no son del LCD The subroutines: ; Posiciona el cursor del LCD en la posici—n que marca W ; Las direcciones para el locate en un LCD 16x2 son: ; +-------------------------------------------------+ ; | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | ; | 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F | ; +-------------------------------------------------+ locate iorlw B'10000000'; Asegura "Set DDRAM address" ; y env’a el comando (princmd) ; Env’a byte en W al LCD (Bus de 4 bits) princmd bcf lcd_rs ; El byte es un comando goto envlcd princhr bsf lcd_rs ; El byte es un car‡cter envlcd movwf aux ; Salva el car‡cter movlw lcdmasc ^ B'11111111'; Salva los 4 bits andwf lcdbus,W ; del puerto del LCD que no per- movwf aux1 ; tenecen al dato a transmitir movf aux,W ; Une el primer nibble a enviar andlw lcdmasc ; con la parte del puerto preser- iorwf aux1,W ; vada... movwf lcdbus bsf lcd_e ; y lo env’a. nop bcf lcd_e swapf aux,W ; Lo mismo con el segundo nibble andlw lcdmasc iorwf aux1,W movwf lcdbus bsf lcd_e ; y lo env’a. nop bcf lcd_e ; ...y espera 100us ; Bucle de espera de 100us=0.1ms. S—lo afecta al reg. W buc100 movlw d'256'-d'100'*fosc/4/4 ; | | | +-> instrucciones/bucle ; | | +---> cicl_reloj/instruc. ; | +------> Frec. cristal (MHz) ; +------------> 100us addlw D'1' btfss STATUS,Z goto $-2 return -----Mensaje original----- De: McMeikan, Andrew Para: PICLIST@MITVMA.MIT.EDU Fecha: lunes, 30 de agosto de 1999 11:50 Asunto: Re: LCD DDRAM address problems >Hi Alvaro, > I assume that you are sending this with bit 7 high, most data sheets >call the addresses 80-8F and C0-CF to avoid that ambiguity, other wise you >should have no problem, what about a snippet of the source code? pin >assignments, do you have a pin open-collector? > > cya, Andrew... > >> -----Original Message----- >> From: Alvaro Deibe Diaz [SMTP:adeibe@CDF.UDC.ES] >> Sent: Monday, August 30, 1999 5:13 PM >> To: PICLIST@MITVMA.MIT.EDU >> Subject: LCD DDRAM address problems >> >> Hi piclisters, >> >> I have problems trying to make a "locate" in an Optrex LCD. The LCD has >> the >> typicall Hitachi 77480 in it. It is 16char x 2lines, so I suppose the >> DDRAM >> address for the 32 possible locations (without shift) are: >> >> 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F >> 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F >> >> The "Set DDRAM Address" command seems to work OK for the last 15 char in >> each line, but fails with addresses '00' and '40', apparently "hanging" >> the >> 44780. ÀAny ideas? >> >> Note: the interface is 4-bits long, and the uC a 16C65 >> >> Thanks. >