|
|
View previous topic :: View next topic |
Author |
Message |
lacolo
Joined: 10 Mar 2006 Posts: 15
|
issues with multiple LCDs and the "ready" flag |
Posted: Wed Apr 05, 2006 12:25 am |
|
|
Hello,
I am working on an installation with one PIC18F452 driving 10 LCDs (VK2220 - http://www.wrighthobbies.net/datasheets/VK2220.pdf)
I've modified the LCD.c to be able to communicate with various LCD panels. That is working fine, but I have an issue I want to be able to prevent.
Currently, if one LCD fails (in hardware), the entire program will stall.
This is because the LCD_sendByte() routine in LCD.c (modified) waits for a "ready" flag before it communicates with a panel. If that panel doesn't respond, the program doesn't progress.
Any suggestions on what I can do on the hardware side, so that a "lack of response" doesn't stall the program? OR, any suggestions on the software side on some if statement to precede LCD_sendByte()?
Thanks!
//Cynthia |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Wed Apr 05, 2006 3:06 am |
|
|
You could change the send byte function to take a timeout value (in microseconds) and a return flag indicating success or a timeout (failure).
Code: | int1 lcd_send_byte( BYTE address, BYTE n, int8 timeout ) {
int8 count;
lcd.rs = 0;
count = 0;
while ( bit_test(lcd_read_byte(),7) )
{
delay_us(1);
count++;
if (count >= timeout )
{
// timed out ...
return false;
}
};
lcd.rs = address;
delay_cycles(1);
lcd.rw = 0;
delay_cycles(1);
lcd.enable = 0;
lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
// success
return true;
}
|
you may also want to change the lcd_getc to use the same timeout mechanism.
In this example I have defined the timeout as as int8 so a maximum of 255us is possible, you chould change the delay_us to use delay_ms or increase the granularity from 1us to 10 or 100 us by changing the delay_us(xx) statement. It all depends on how long your application can tolerate the function stalling the program (in the worst case of a display failing to respond). _________________ Regards,
Simon. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|