when i run this code in proteus the hours digits doesnt appear
i use pic16f877a with 4mhz crystal
this is mycode:
// Lcd pinout settings
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
//constans
unsigned int minute;
unsigned int hour;
unsigned int second;
char mins[6];
char hours[6];
//interrupt routine
void interrupt(){
if(PIR1.TMr1IF){
if(second==10){
second=0;
minute=minute+1;
}
if(minute==60){
minute=0;
second=0;
hour=hour+1;
}
if(hour==24){
hour=0;
minute=0;
second=0;
}
second=second+1;
PIR1.TMr1IF=0;
}
}
// main routine
void main() {
trisb=0;
portb=0;
Lcd_init();
Lcd_cmd(_LCD_CURSOR_OFF);
Lcd_cmd(_LCD_CLEAR);
Lcd_out(1,3,ltrim(":"));
INTCON.GIE=1;
INTCON.PEIE=1;
PIR1.TMr1IF=0;
PIE1.TMR1IE=1;
TMR1H=0xFB;
TMR1L=0x1E;
T1CON.T1CKPS1=1;
T1CON.T1CKPS0=1;
T1CON.T1OSCEN=1;
T1CON.T1SYNC=0;
T1CON.TMR1CS=0;
T1CON.TMR1ON=1;
while(1){
ByteToStr(minute,mins);
ByteToStr(hour,hours);
Lcd_out(1,1,ltrim(hour));
Lcd_out(1,4,ltrim(mins));
}
}
cant display correct values on lcd
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: cant display correct values on lcd
Hi,
Can you tell me do you use some development system or some custom hardware?
I believe that you didn't initialize your LCD properly. Please double check you initialization of LCD.
Note that Proteus is not officially supported by mikroElektronika, and we suggest our users to test their examples on real hardware.
Best regards,
Aleksandar
Can you tell me do you use some development system or some custom hardware?
I believe that you didn't initialize your LCD properly. Please double check you initialization of LCD.
Note that Proteus is not officially supported by mikroElektronika, and we suggest our users to test their examples on real hardware.
Best regards,
Aleksandar
Re: cant display correct values on lcd
i use custom hardware. but what do u believe is wrong in initializing the lcd ?
thank you
thank you
Re: cant display correct values on lcd
Hi,
ltrim is not a function. So, usein stead of
Also this wont work:
Leave the ltrim out:
ltrim is not a function. So, use
Code: Select all
ltrim(hour);
Lcd_out(1,1,hour);
ltrim(mins)
Lcd_out(1,4,mins);
Code: Select all
Lcd_out(1,1,ltrim(hour));
Lcd_out(1,4,ltrim(mins));
Code: Select all
Lcd_out(1,3,ltrim(":"));
Code: Select all
Lcd_out(1,3,":");
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)