Page 1 of 1
help please in this code
Posted: 04 Jun 2010 03:01
by Eng_Bandar
I simulated the following circuit by proteus
my project if press the switch the message in LCD will appear but here the message appear before pressing Why? What is the problem ?
this is my code in MikroC
Code: Select all
char *text = "Hello world";
void main(){
TRISD=0xff;
while(1){
if(portd.f0==0){
Lcd_Init(&PORTB);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Out(2,1,text);
}
}
}
Re: help please in this code
Posted: 04 Jun 2010 13:09
by Sobrietytest
Try this...
Code: Select all
char *text = "Hello world";
void main(){
TRISD = 0xff;
Lcd_Init(&PORTB);
Lcd_Cmd(_LCD_CLEAR);
while(1){
if(portd.f0 == 0){
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Out(2,1,text);
}
else{
Lcd_Cmd(_LCD_CLEAR);
}
}
}
Re: help please in this code
Posted: 04 Jun 2010 15:35
by Eng_Bandar
I tried your code come this error
Re: help please in this code
Posted: 04 Jun 2010 17:43
by basicbasic111
r u using 16f877?
hmmmmmmmm
I only changed Sobrie's code to c pro 3.8
everything worked perfectly on my latest version of proteus
by the way two of your diagrams are tiny
i cannot see them clearly
I only changed these few parts for c pro 3.8
1
Code: Select all
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
2
3.
with a (_) within
that's it
I am sure we can work this out.
Please tell me which pic you are using
and which version of c you are using too
I will try to use the old version of c and make it work for you
Re: help please in this code
Posted: 04 Jun 2010 19:35
by Eng_Bandar
^^^^^^^^
Thank guys for your helping
I use pic16f877
about version of mikroc
mikroC, mikroElektronika C compiler
for Microchip PIC microcontrollers
Version: 8.1.0.0
about error
about connection ( may find error from connection )
Re: help please in this code
Posted: 04 Jun 2010 20:30
by basicbasic111
working code :
Code: Select all
char *text = "Hello world";
void main() {
TRISD = 0xff;
Lcd_Init(&PORTB);
Lcd_Cmd(LCD_CLEAR);
while(1){
if(portd.f0 == 0){
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Out(2,1,text);
}
else{
Lcd_Cmd(LCD_CLEAR);
}
}
}
settings default 8M external
Change your lcd connections as follows
Lcd_Init(&PORTB);
it means
D7 → portb.f7
D6 → portb.f6
D5 → portb.f5
D4 → portb.f4
E → portb.f3
RS → portb.f2
RW → portb.f0
try to link up the wires without using the bus
I simulated the above code and followed these connections
it worked very well on my latest proteus
hope it helps
Good luck!
Re: help please in this code
Posted: 05 Jun 2010 05:40
by Eng_Bandar
Thank basicbasic111 & Sobrietytest for your helping
Thank you so much
the project executed