PA3040
Advanced Member level 3
- Joined
- Aug 1, 2011
- Messages
- 883
- Helped
- 43
- Reputation
- 88
- Reaction score
- 43
- Trophy points
- 1,308
- Activity points
- 6,936
void lcddata(unsigned char value)
{
LCD_RS = 1;
LCD_DATA= (value&0xf0);
LCD_STROBE;
LCD_DATA = ((value<<4)&0xf0);
LCD_STROBE;
__delay_ms(10);
}
void lcddata(unsigned char value)
{
LCD_RS = 1;
LCD_DATA= ((value>>4)&0x0f);
LCD_STROBE;
LCD_DATA = (value&0x0f);
LCD_STROBE;
__delay_ms(10);
}
void lcdcmd(unsigned char value)
{
LCD_RS = 0;
LCD_DATA= ((value>>4)&0x0f);
LCD_STROBE;
LCD_DATA = (value&0x0f);
LCD_STROBE;
__delay_ms(10);
}
LCD_EN =0;
__delay_us(10);
LCD_DATA =0X30;
LCD_STROBE;
__delay_ms(2);
LCD_RS=0;
__delay_us(10);
LCD_DATA =0X30;
LCD_STROBE;
__delay_ms(2);
LCD_RS=0;
__delay_us(10);
LCD_DATA =0X30;
LCD_STROBE;
__delay_ms(2);
LCD_RS=0;
__delay_us(10);
LCD_DATA =0X20;
LCD_STROBE;
__delay_ms(2);
lcdcmd(0x28);
__delay_ms(15);
lcdcmd(0x01);
__delay_ms(10);
lcdcmd(0x06);
__delay_ms(10);
lcdcmd(0x80);
__delay_ms(10);
lcdcmd(0x0c);
__delay_ms(10);
LCD_EN =0;
__delay_us(10);
LCD_DATA =0X3;
LCD_STROBE;
__delay_ms(2);
LCD_RS=0;
__delay_us(10);
LCD_DATA =0X3;
LCD_STROBE;
__delay_ms(2);
LCD_RS=0;
__delay_us(10);
LCD_DATA =0X3;
LCD_STROBE;
__delay_ms(2);
LCD_RS=0;
__delay_us(10);
LCD_DATA =0X2;
LCD_STROBE;
__delay_ms(2);
void lcddata(unsigned char value)
{
LCD_RS = 1;
LCD_DATA= ((value>>4)&0x0f);
LCD_STROBE;
LCD_DATA = (value&0x0f);
LCD_STROBE;
__delay_ms(10);
}
void lcdcmd(unsigned char value)
{
LCD_RS = 0;
LCD_DATA= ((value>>4)&0x0f);
LCD_STROBE;
LCD_DATA = (value&0x0f);
LCD_STROBE;
__delay_ms(10);
}
void lcd_init()
{
EN=0;
LCD_RS = 0;
__delay_us(10);
LCD_DATA=0X0c;
ENBL;
__delay_ms(2);
LCD_RS = 0;
__delay_us(10);
LCD_DATA=0X0c;
LCD_STROBE;
__delay_ms(2);
LCD_RS = 0;
__delay_us(10);
LCD_DATA=0X0c;
LCD_STROBE;
__delay_ms(2);
LCD_RS = 0;
__delay_us(10);
LCD_DATA=0X04;
LCD_STROBE;
__delay_ms(2);
lcdcmd(0X28);
__delay_ms(5);
lcdcmd(0X0);
__delay_ms(5);
lcdcmd(0X01);
__delay_ms(5);
lcdcmd(0X06);
__delay_ms(5);
void lcddata(unsigned char val)
{
//8bit reversing
val = (val & 0x0F) << 4 | (val & 0xF0) >> 4;
val = (val & 0x33) << 2 | (val & 0xCC) >> 2;
val = (val & 0x55) << 1 | (val & 0xAA) >> 1;
LCD_RS = 1;
LCD_DATA=(val&0x0f);
LCD_STROBE;
LCD_DATA =((val>>4)&0x0f);
LCD_STROBE;
__delay_ms(10);
}
void lcdcmd(unsigned char val)
{
//8bit reversing
val = (val & 0x0F) << 4 | (val & 0xF0) >> 4;
val = (val & 0x33) << 2 | (val & 0xCC) >> 2;
val = (val & 0x55) << 1 | (val & 0xAA) >> 1;
LCD_RS = 0;
LCD_DATA=(val&0x0f);
LCD_STROBE;
LCD_DATA =((val>>4)&0x0f);
LCD_STROBE;
__delay_ms(10);
}
#include <htc.h>
#define _XTAL_FREQ 4000000 // 4 MHz clock
__CONFIG(0X3F39);
#define LCD_EN RC6
#define LCD_RS RC7
#define LCD_DATA PORTD
#define LCD_STROBE LCD_EN = 1; __delay_ms(1); LCD_EN=0;
unsigned char time [6] = {"Time:"};
void lcddata(unsigned char value)
{
LCD_RS = 1;
LCD_DATA= (value&0x0f);
LCD_STROBE;
LCD_DATA = ((value>>4)&0x0f);
LCD_STROBE;
__delay_ms(10);
}
void lcdcmd(unsigned char value)
{
LCD_RS = 0;
LCD_DATA= (value&0x0f);
LCD_STROBE;
LCD_DATA = ((value>>4)&0x0f);
LCD_STROBE;
__delay_ms(10);
}
void display (){
lcdcmd(0x80);
for (char i=0;i<5;i++){
lcddata(time[i]);
}
}
void lcd_init(){
TRISD = 0;
TRISB = 0;
TRISC = 0;
__delay_us(10);
lcdcmd(0x03);
__delay_us(10);
lcdcmd(0x03);
__delay_us(10);
lcdcmd(0x03);
__delay_us(10);
lcdcmd(0x2);
__delay_us(10);
LCD_STROBE;
__delay_ms(2);
lcdcmd(0x28);
__delay_ms(15);
lcdcmd(0x01);
__delay_ms(10);
lcdcmd(0x06);
__delay_ms(10);
lcdcmd(0x80);
__delay_ms(10);
lcdcmd(0x0c);
__delay_ms(10);
}
void main(){
lcd_init();
while(1){
display();
}
}
the above program is not working in proteus why?Dear justing
Thanks for the reply
please see the codes and advice with wrong
Code:#include <htc.h> #define _XTAL_FREQ 4000000 // 4 MHz clock __CONFIG(0X3F39); #define LCD_EN RC6 #define LCD_RS RC7 #define LCD_DATA PORTD #define LCD_STROBE LCD_EN = 1; __delay_ms(1); LCD_EN=0; unsigned char time [6] = {"Time:"}; void lcddata(unsigned char value) { LCD_RS = 1; LCD_DATA= (value&0x0f); LCD_STROBE; LCD_DATA = ((value>>4)&0x0f); LCD_STROBE; __delay_ms(10); } void lcdcmd(unsigned char value) { LCD_RS = 0; LCD_DATA= (value&0x0f); LCD_STROBE; LCD_DATA = ((value>>4)&0x0f); LCD_STROBE; __delay_ms(10); } void display (){ lcdcmd(0x80); for (char i=0;i<5;i++){ lcddata(time[i]); } } void lcd_init(){ TRISD = 0; TRISB = 0; TRISC = 0; __delay_us(10); lcdcmd(0x03); __delay_us(10); lcdcmd(0x03); __delay_us(10); lcdcmd(0x03); __delay_us(10); lcdcmd(0x2); __delay_us(10); LCD_STROBE; __delay_ms(2); lcdcmd(0x28); __delay_ms(15); lcdcmd(0x01); __delay_ms(10); lcdcmd(0x06); __delay_ms(10); lcdcmd(0x80); __delay_ms(10); lcdcmd(0x0c); __delay_ms(10); } void main(){ lcd_init(); while(1){ display(); } }
Thanks in advance
- - - Updated - - -
Dear justing
Thanks for reply
I got the point
It was great lesson and i studied lot from you
Thanks again and again for help
PA3040
the above program is not working in proteus why?
Above codes two parts are missing ..what is it?
me too don't know i am completely new to embedded.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?