I always try not to disturb you people here with my easy question by try to dig solutions by myself, but today I fed up again with LCD.
With almost 3 years of microcontroller experience I suppose to learn how to program LCD in C, unfortunately no as I learn flowcode in my school
So I struggle every time exploring new modules, like last time I ever ask how to make alphabet words input into ASCII and sent to a vintage VFD.
Yes, this is my second experience on display but it is a LCD with newer tech and instruction compare to my VFD.
Skip my story here.....
My LCD model is 16 pins I/O(incl a LED anode and cathode) 1602A and I had research that it instructions are same as the commonly used Hitachi HD44780U 16x2 display.
I had attach the datasheet I refers to and comparing other 1602 datasheet I get similar display characteristic.
below is my code
#include <htc.h>
#include <pic.h>
#define _XTAL_FREQ 1000000
void write(unsigned char RS , unsigned char data)
{
RA7 = 0; //R/W
RA0 = RS; //RS
__delay_us(0.15); //RS and RW setup time
RA6 = 1; //EN
LATB = data;
__delay_us(0.3); //Tw, minimum EN rise time
__delay_us(0.01); //Th2, minimum wait time for data clear after EN fall
LATB = 0x00;
__delay_us(0.19); //Tc, sum from Tw for minimum cycle time of EN
}
void init_LCD(void)
{
TRISA = 0x00; //RA0 is RS, RA7 is R/W, RA6 is EN
TRISB = 0x00; //8 bit data port
LATA = 0x00;
LATB = 0x00;
//ASSUME INITIAL FUNCTION MODE IS 4 Bits
// write(0 , 0b00111000); //set functions, sent first 4 MSB bits 8bits bus mode, 2 lines display, 5*8 dots format
// write(0 , (0b00111000<<4)); //set functions, send last 4 LSB bits
//ASSUME INITIAL FUNCTION MODE IS 8 Bits
write(0 , 0b00111000); //set functions, 8bits bus mode, 2 lines display, 5*8 dots format
write(0 , 0b00000001); //clear display
write(0 , 0b00000010); //return cursor to home
write(0 , 0b00001110); //display on/off control, display on, cursor on, cursor blink off
}
void main(void)
{
OSCCON = 0b01011010; //1MHz Fosc, Int Osc module
__delay_ms(400);
init_LCD();
write(0, 0b01000101); //try to print a alphabet first, "E" in ASCII
for(;;)
{
}
}
PROBLEM is here
I try a few codes from Hi-Tech C sample code to code that I get from the internet(modify their I/O config to specific pic I use)...
The codes had a successful built and programmed into my PIC.
but then I still get a blank on my LCD(attached picture)
so I wonder anyone had try 1602A LCD and give my code correction or a sample display test code.
This is my first LCD and I really afraid that it is broken.
Picture LCD : when the power is off the screen appear dark... the bottom part show slightly poor contrast as my V0 are tuned by 10k ohm resistor, both device are power up by USB power.
Picture VFD : This VFD is about 27 years old, so the controller is still using NEC 8041 where lots of SIPO to multi task the matrix.
LCD command from website :
http://mil.ufl.edu/3744/docs/lcdmanual/commands.html