Please tell me what is wrong with my initiazation code.
SYSTEM_Initialize();
Initialize_NHD();
Update_NHD(5, 5, 5);
while (1){}
void Initialize_NHD(){
LATCbits.LATC0 = 0; //Data Bit 0
LATCbits.LATC1 = 0; //Data Bit 1
LATCbits.LATC2 = 0; //Data Bit 2
LATCbits.LATC3 = 0; //Data Bit 3 Data = 0x00
LATCbits.LATC5 = 1; //E Enable - Falling Edge Triggered
LATCbits.LATC6 = 0; //R/W 1=Read 0=Write
LATCbits.LATC7 = 0; //RS 1=Data 0=Command
__delay_ms(100);
LATCbits.LATC0 = 1; //Data Bit 0
LATCbits.LATC1 = 1; //Data Bit 1 = 0x03 on port
__delay_ms(30);
LATCbits.LATC5 = 1; //E = 1
__delay_ms(1); //Nybble
LATCbits.LATC5 = 0; //E = 0
__delay_ms(10);
LATCbits.LATC5 = 1; //E = 1
__delay_ms(1); //Nybble
LATCbits.LATC5 = 0; //E = 0
__delay_ms(10);
LATCbits.LATC5 = 1; //E = 1
__delay_ms(1); //Nybble
LATCbits.LATC5 = 0; //E = 0
__delay_ms(10);
LATCbits.LATC0 = 0; //Data Bit 0
LATCbits.LATC1 = 1; //Data Bit 1 = 0x02 on port
LATCbits.LATC5 = 1; //E = 1
__delay_ms(1); //Nybble
LATCbits.LATC5 = 0; //E = 0
Command_NHD(0x28); //4-bit Interface
Command_NHD(0x10); //Set Cursor
Command_NHD(0x0F); //Display ON, Cursor NOT Blinking
Command_NHD(0x06); //Entry Mode Set
}
void Command_NHD(unsigned char data_uc){
__delay_ms(1); //Delay 1mS
LATCbits.LATC7 = 0; //RS = 0 = command
LATCbits.LATC6 = 0; //R/W = 0 = write
if((data_uc & 0x10) == 0x10) LATCbits.LATC0 = 1;
else LATCbits.LATC0 = 0;
if((data_uc & 0x20) == 0x20) LATCbits.LATC1 = 1;
else LATCbits.LATC1 = 0;
if((data_uc & 0x40) == 0x40) LATCbits.LATC2 = 1;
else LATCbits.LATC2 = 0;
if((data_uc & 0x80) == 0x80) LATCbits.LATC3 = 1;
else LATCbits.LATC3 = 0;
LATCbits.LATC5 = 1; //E = 1
__delay_ms(1); //Delay 1mS
LATCbits.LATC5 = 0; //E = 0
if((data_uc & 0x10) == 0x10) LATCbits.LATC0 = 1;
else LATCbits.LATC0 = 0;
if((data_uc & 0x20) == 0x20) LATCbits.LATC1 = 1;
else LATCbits.LATC1 = 0;
if((data_uc & 0x40) == 0x40) LATCbits.LATC2 = 1;
else LATCbits.LATC2 = 0;
if((data_uc & 0x80) == 0x80) LATCbits.LATC3 = 1;
else LATCbits.LATC3 = 0;
LATCbits.LATC5 = 1; //E = 1
__delay_ms(1); //Delay 1mS
LATCbits.LATC5 = 0; //E = 0
}
void Data_NHD(unsigned char data_uc){
__delay_ms(1); //Delay 1mS
LATCbits.LATC7 = 1; //RS = 1 = data
LATCbits.LATC6 = 0; //R/W = 0 = write
if((data_uc & 0x01) == 0x01) LATCbits.LATC0 = 1;
else LATCbits.LATC0 = 0;
if((data_uc & 0x02) == 0x02) LATCbits.LATC1 = 1;
else LATCbits.LATC1 = 0;
if((data_uc & 0x04) == 0x04) LATCbits.LATC2 = 1;
else LATCbits.LATC2 = 0;
if((data_uc & 0x08) == 0x08) LATCbits.LATC3 = 1;
else LATCbits.LATC3 = 0;
LATCbits.LATC5 = 1; //E = 1
__delay_ms(1); //Delay 1mS
LATCbits.LATC5 = 0; //E = 0
if((data_uc & 0x10) == 0x10) LATCbits.LATC0 = 1;
else LATCbits.LATC0 = 0;
if((data_uc & 0x20) == 0x20) LATCbits.LATC1 = 1;
else LATCbits.LATC1 = 0;
if((data_uc & 0x40) == 0x40) LATCbits.LATC2 = 1;
else LATCbits.LATC2 = 0;
if((data_uc & 0x80) == 0x80) LATCbits.LATC3 = 1;
else LATCbits.LATC3 = 0;
LATCbits.LATC5 = 1; //E = 0
__delay_ms(1); //Delay 1mS
LATCbits.LATC5 = 0; //E = 1
}
void Update_NHD(unsigned char Digit_1_uc,
unsigned char Digit_2_uc,
unsigned char Digit_3_uc){
// Command_NHD((unsigned char)(0x18)); //Set pointer to right shifting left
// Data_NHD((unsigned char)(Digit_1_uc | 0x30));
// Data_NHD((unsigned char)(Digit_2_uc | 0x30));
// Data_NHD((unsigned char)(Digit_3_uc | 0x30));
Data_NHD(0x30);
Data_NHD(0x31);
Data_NHD(0x32);
Data_NHD(0x33);
Data_NHD(0x34);
Data_NHD(0x35);
Data_NHD(0x36);
Data_NHD(0x37);
Data_NHD(0x38);
// Command_NHD(24);
// Data_NHD(52);
}