hi-tech lcd_puts() function vs. interrupts (+ PWM toggle question)
Hi all,
I've noticed a strange thing when using the lcd_puts() function with the Hi-Tech complier. It works fine with the following bit of code:
[effectively moving around digits in a number to fit a 4 digit space ie. display 9 as 00.9, 99 as 09.9 and 999 as 99.9]
Later on I've added an interrupt service routine and noticed that the above function shows values on the LCD, but also displays a strange Chinese looking character at the end of each number, for example instead of 09.9 I'd see 09.9#, where # is the strange character (it's not a hash character though, it's one I couldn't even find on ASCII tables :O). That character changes as I change the value displayed, I can see at some point is simply follows the ASCII table up/down depending what I do with the displayed value (it's controlled of a rotary encoder).
Now the funny thing, buf is defined as a variable buf[4]. Without the interrupt service routine that works ok, with an interrupt routine it shows a character at the end, but if I make buf a longer array and use buf[5], it works good again. Here's lcd_puts():
Anyone knows why?
Regards,
T.
Hi all,
I've noticed a strange thing when using the lcd_puts() function with the Hi-Tech complier. It works fine with the following bit of code:
Code:
void show_time(void) //update LCD with new time value
{
itoa(buf, time, 10);
if(time<10) {buf[3] = buf[0]; buf[0] = '0'; buf[1] = '0'; buf[2] = '.';}
if(time>=10 && time<100) {buf[3] = buf[1]; buf[1] = buf[0]; buf[0] = '0'; buf[2] = '.'; }
if(time>=100) {buf[3] = buf[2]; buf[2] = '.';}
lcd_goto(0x46);
lcd_puts(buf);
}
[effectively moving around digits in a number to fit a 4 digit space ie. display 9 as 00.9, 99 as 09.9 and 999 as 99.9]
Later on I've added an interrupt service routine and noticed that the above function shows values on the LCD, but also displays a strange Chinese looking character at the end of each number, for example instead of 09.9 I'd see 09.9#, where # is the strange character (it's not a hash character though, it's one I couldn't even find on ASCII tables :O). That character changes as I change the value displayed, I can see at some point is simply follows the ASCII table up/down depending what I do with the displayed value (it's controlled of a rotary encoder).
Now the funny thing, buf is defined as a variable buf[4]. Without the interrupt service routine that works ok, with an interrupt routine it shows a character at the end, but if I make buf a longer array and use buf[5], it works good again. Here's lcd_puts():
Code:
void lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}
Anyone knows why?
Regards,
T.
Last edited: