Hi,
I am currently doing my project and i need to test my microcontroller with an LCD screen, i am using HI-tech compiler on mp lab. my code builds but does not display anything or put on the LCD. Please Help
Here is what i mapped the microcontroller pins to
RD4 to LCD_RS
RD5 to LCD_EN
RD0 to LCD_D4
RD1 to LCD_D5
RD2 to LCD_D6
RD3 to LCD_D7
Here is my software:#ifndef _XTAL_FREQ// Unless specified elsewhere, 4MHz system frequency is assumed#define _XTAL_FREQ 8000000#endif#include <htc.h>#include "lcd.h"#define LCD_RS RD4#define LCD_EN RD5#define LCD_DATA PORTD#define LCD_STROBE() ((LCD_EN = 1),(LCD_EN=0))/* write a byte to the LCD in 4 bit mode */void
lcd_write(unsignedchar c){
__delay_us(40);
LCD_DATA =(( c >>4)&0x0F);
LCD_STROBE();
LCD_DATA =( c &0x0F);
LCD_STROBE();}/* * Clear and home the LCD */void
lcd_clear(void){
LCD_RS =0;
lcd_write(0x1);
__delay_ms(2);}/* write a string of chars to the LCD */void
lcd_puts(constchar* s){
LCD_RS =1;// write characterswhile(*s)
lcd_write(*s++);}/* write one character to the LCD */void
lcd_putch(char c){
LCD_RS =1;// write characters
lcd_write( c );}/* * Go to the specified position */void
lcd_goto(unsignedchar pos){
LCD_RS =0;
lcd_write(0x80+pos);}/* initialise the LCD - put into 4 bit mode */void
lcd_init(){char init_value;
init_value =0x3;
TRISA=0;
TRISD=0;
LCD_RS =0;
LCD_EN =0;
__delay_ms(15);// wait 15mSec after power applied,
LCD_DATA = init_value;
LCD_STROBE();
__delay_ms(5);
LCD_STROBE();
__delay_us(200);
LCD_STROBE();
__delay_us(200);
LCD_DATA =2;// Four bit mode
LCD_STROBE();
lcd_write(0x28);// Set interface length
lcd_write(0xF);// Display On, Cursor On, Cursor Blink
lcd_clear();// Clear screen
lcd_write(0x6);// Set entry Mode}
hi
why you are not mention lcd READ/WRITE pin your program ?
are you connect lcd read/write pin in your microcontroller?
check your circuit and write coding like RD6 to LCD_RW
read your lcd header file and also read inside lcd_write function
---------- Post added at 13:50 ---------- Previous post was at 13:45 ----------
lcd read write pin is important to display what u like to display so connect ur lcd read/write pin to ur micro controller i/o pin & mention that i/0 pin in your codings like this #define LCD_EN RD5
The direction of data transfer is controlled by the R/W pin. If it is pulled Low, the commands or character data is written to the LCD module. And, when it is pulled high, the character data or status information from the LCD registers is read. Here, we will use one way data transfer, i.e., from microcontroller to LCD module, so the R/W pin will be grounded permanently. i have attached a picture of my LCD circuit
its correct lcd read write pin takes low means write data to lcd.high means read data.your circuit connected to low signal.so lcd write data continiously.when the pin is set to high means its display ur codings data.