Thanks for all the help but I still can't get it to work. How do I do to get the asemblercode from Ht-pic, all I get is a lstfile and a hexfile. I have rewritten the parts that was wrong. When I turn on the power the LCD won't print "PETER". It won't even initialized. All that happens is that the LCD:s first row is black. I know that the LCD is working because I have tested it with some asemblercode that I have written. How do I make a delay in c? Is my delayroutine working (It should wait x millisec.)? //Peter Code ---------------------------------- unsigned char STATUS @ 0x03; unsigned char PORTA @ 0x05; unsigned char PORTB @ 0x06; unsigned char TRISA @ 0x85; unsigned char TRISB @ 0x86; #define SETBIT(x,y) (x |= (y)) /* Set bit y in byte x*/ #define CLEARBIT(x,y) (x &= (~y)) /* Clear bit y in byte x*/ #define CHECKBIT(x,y) (x & (y)) /* Check bit y in byte x*/ #define BYTE int #define RP0 0b00100000 #define RS 0b00001000 #define E 0b00000100 #define CLK 0b00000001 #define DATA 0b00000010 void port_init(void); void send_command(BYTE cmd); void send_ascii(BYTE ascii); void send(BYTE word); void busy_check(void); void manuell_reset(void); void delay_ms (BYTE ms); void shift(BYTE word); main() { port_init(); manuell_reset(); send_ascii('P'); send_ascii('e'); send_ascii('t'); send_ascii('e'); send_ascii('r'); } void port_init(void) { TRISA = 0; /* Outputs */ TRISB = 0; } void send_command(BYTE cmd) { CLEARBIT(PORTA, RS); /* Send a command */ send(cmd); } void send_ascii(BYTE ascii) { SETBIT(PORTA, RS); /* Send ASCII */ send(ascii); } void send(BYTE word) { shift(word); /* Shift the word to the shiftregister */ SETBIT(PORTA, E); /* Enable high/low */ CLEARBIT(PORTA, E); delay_ms(1); /* Wait */ } void shift(BYTE word) { char i; for(i=0;i<=7;i++) /* shift out msb first */ { if (CHECKBIT(word,7) == 1) { SETBIT(PORTB,DATA); /* If high set PORTB,1 and clock it out */ }else{ CLEARBIT(PORTB,DATA); /* If low set PORTB,1 and clock it out */ } SETBIT(PORTB,CLK); /* clock it out to the seriell_in/parallell out shiftregister */ CLEARBIT(PORTB,CLK); word <<= 1; /* shift one bit */ } } void manuell_reset(void) { delay_ms(5); /* wait */ delay_ms(5); delay_ms(5); PORTB = 0b00111000; /* 8 bit databus */ SETBIT(PORTA, E); delay_ms(5); CLEARBIT(PORTA, E); SETBIT(PORTA, E); delay_ms(5); CLEARBIT(PORTA, E); SETBIT(PORTA, E); delay_ms(5); CLEARBIT(PORTA, E); send_command(0b00111000); send_command(0b00001100); send_command(0b00000001); send_command(0b00000110); } void delay_ms(BYTE ms) { BYTE i,j; for (i = 0; i < ms; i++) { for (j = 0; j < 1000; j++) { #asm nop #endasm } } } -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body