This is my PIC circuit connection in Proteus to the LCD display and everything work fine in simulation. However, in practice, my LCD does not display even the very first line "AC Wattmeter" in the "void main()".
Since the code is very long, I only pasted a portion of the code relevant to it.
I tried the same circuit design as below with other code and the LCD display working fine. Have tried to tune the potentiometer for contrast yet not showing anything. Trying to debug for quite sometime yet have no idea where the problem is. Have tested changing the delay ms to 5ms in the LCD set and command method yet same issue.
#pragma config FOSC = HS // Oscillator Selection bits (XT oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial
Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM
code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write
protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code
protection off)
#include <xc.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#define rs RB0
#define rw RB1
#define e RB2
#define _XTAL_FREQ 20000000
volatile bool CountWaveFormEnable=false;
void LCD_set(unsigned char initialize);
void LCD_command(unsigned char Var);
void initialize();
void Write();
void CharToString(const char *character,unsigned char number);
char* floattostr(float num);
void lCD_command();
void init()
{
TRISA = 0xFF;
TRISD = 0x00;
TRISB = 0b11000000;
T1CON = 0x01;
ADCON0 = 0b01001001;
ADCON1 = 0b11000000;
INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;
PIE1bits.CCP1IE = 1;
CCP1CON = 0x05;
OPTION_REG = 0x07;
TMR0 = 0;
a = 0;
b = 0;
}
void main()
{
init();
initialize();
CharToString(" AC Wattmeter",14);
__delay_ms(500);
LCD_set(0x01);
while(1)
{
//Do something
}
}
void initialize()
{
LCD_set(0x0c);
LCD_set(0x38);
LCD_set(0x80);
}
void LCD_command(unsigned char Var)
{
PORTD = Var;
rs = 1;
rw = 0;
e = 0;
__delay_ms(0.1);
e = 1;
}
void LCD_set(unsigned char initialize)
{
PORTD=initialize;
rs = 0;
rw = 0;
e = 0;
__delay_ms(0.1);
e = 1;
}
void CharToString(const char *character,unsigned char number)
{
for(int i=0; i<number; i++)
{
LCD_command(character[i]);
}
}
char string[3];
char* floattostr(float num)
{
sprintf(string, "%d.%02u", (int)(num), ((int)(num*100)%100));
return string;
}
__delay_ms()
function accepts non-integer values? I'm almost certain that it doesn't, and as a result all your delays are zero-length. \$\endgroup\$