Ovladani LCD HD44780 s PIC24HJ32GP202 v C30

Dobry den.
Mam mensi problem s rozchozenim komunikace LCD s timto PICem. Kod vypada nasledovne:

#include <p24hxxxx.h>
#define FCY 10000000UL


void lcd_line1(void);			//function prototypes
void lcd_line2(void);
void lcd_cmd(unsigned char);
void lcd_char(char);
void e_togg(void);
void lcd_init(void);
void lcd_string();
void delay(void);
void del_5ms(void);
//void lcd_busy(void);

char sentence[16] = "Tome, lets go!";
char *senpoint = sentence;

#define	E		LATAbits.LATA1
#define	RS		LATAbits.LATA0

int main(void)
{	

	AD1PCFGL = 0xffff;		//all digital
	TRISA = 0;			//PORTs all outputs
	TRISB = 0;
	E = 0;				//set E low
	lcd_init();
	delay();
	lcd_string();			//send string to LCD
	for(;;){}			//spin forever
	return 0;
}

void lcd_string(void)
{
	while(*senpoint != '\0')
	{
		lcd_char(*senpoint);
		senpoint++;
	}
}	

	
void lcd_line1(void)
{
	lcd_cmd(0x80);
}

void lcd_line2(void)
{
	lcd_cmd(0xc0);
}		

void lcd_cmd(unsigned char letter)
{
	LATB = letter;			//put char in PORTB
	del_5ms();//lcd_busy();
	PORTB = PORTB << 5;		//shift over to output high 4 bits on RB9,10,11,12
	RS = 0;				//RS low
	e_togg();			//latch the data
	PORTB = PORTB << 4;		//shift over to output low 4 bits
	RS = 0;				//RS low
	e_togg();			//latch it
}

void lcd_char(char letter)
{
	LATB = letter;			//put char in PORTB
	del_5ms();//lcd_busy();
	PORTB = PORTB << 5;		//shift over to output high 4 bits on RB9,10,11,12
	RS = 1;				//RS high
	e_togg();			//latch the data
	PORTB = PORTB << 4;		//shift over to output low 4 bits
	RS = 1;				//RS high
	e_togg();			//latch it
}

void lcd_init(void)
{
	LATB = 0x0600;			//send 3
	e_togg();
	delay();//lcd_busy();
	LATB = 0x0600;
	e_togg();
	del_5ms();//lcd_busy();
	LATB = 0x0600;
	e_togg();
	del_5ms();//lcd_busy();
	LATB = 0x0400;			//send 2 - set 4-bit mode
	e_togg();
	del_5ms();//lcd_busy();
	lcd_cmd(0x28);			//set 4-bit mode and 2 lines
	del_5ms();//lcd_busy();
	lcd_cmd(0x10);			//cursor move & shift left
	del_5ms();//lcd_busy();
	lcd_cmd(0x06);			//entry mode = increment
	del_5ms();//lcd_busy();
	lcd_cmd(0x0d);			//display on - cursor blink on
	del_5ms();//lcd_busy();
	lcd_cmd(0x01);			//clear display
	delay();//lcd_busy();
}

void e_togg(void)
{
	E=1;
	del_5ms();
	E=0;
}

void delay(void)
{
	int var1,var2;
	for(var1=0;var1!=10;var1++)
	{
		for(var2=0;var2!=10000;var2++);
	}
}

void del_5ms(void)
{
	int var1,var2;
	for(var1=0;var1!=10;var1++)
	{
		for(var2=0;var2!=2000;var2++);
	}
}

PIC je rizen primarnim oscilatorem (krystal 10 Mhz). Propojeni mezi LCD a PIC:

D4 - RB9
D5 - RB10
D6 - RB11
D7 - RB12
RS - RA0
E - RA1

Nasledujici otazka, nevite v cem je prosim vas problem?

Popravde jsem zkousel i jednodussi programek jenom na otestovani vystupu z PICka.

TRISB = 0; // all PORTB pins output AD1PCFGL = 0xffff; // all PORTB pins digital LATB = 0xaa;
Na zadnem pinu na PORTB jsem nenameril napeti log 1.

:cry:

Dekuji predem za jakkoukoli odpoved.

Vyřešeno