JC
Joined: 03 Nov 2005 Posts: 7
|
WDT + User Interface on LCD display |
Posted: Wed Mar 22, 2006 9:42 am |
|
|
Hi,
I already posted these questions on the forum yesterday but impossible to find it again... Strange.
Anyway i've got two questions. One concerning the WDT and the other one User interface.
The WDT problem is concerning the Fuse. I can't regulate when the reset will happen. I tried to change the fuses but it resets exactly after the same amount of time.
here is my example:
Code: |
#include <18F4580.h>
//#use delay(clock=20000000,restart_wdt)
#use delay(clock=20000000)
//#FUSES NOWDT
#FUSES WDT32768
//#FUSES WDT16
#FUSES RC //Resistor/Capacitor Osc with CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#include "Display.c"
#include "KeypadBis.c"
void main()
{
long count_outside;
char key;
lcd_init();
kbd_init();
count_outside=0;
switch ( restart_cause() )
{
case WDT_FROM_SLEEP:lcd_gotoxy(1,1);lcd_putc("sleep");break;
case WDT_TIMEOUT:lcd_gotoxy(1,1);lcd_putc("timeout");break;
case MCLR_FROM_SLEEP:lcd_gotoxy(1,1);lcd_putc("MCLR sleep");break;
case NORMAL_POWER_UP:lcd_gotoxy(1,1);lcd_putc("Normal power up");break;
}
setup_wdt(WDT_ON);
lcd_gotoxy(1,2);
printf(lcd_putc,"Hit any key.");
lcd_gotoxy(1,3);
while(TRUE)
{
key=kbd_getc();
if (key!='\0')
{
restart_wdt();
printf(lcd_putc,"%c",key);
}
}
}
|
1) Does someone see any error or have an explaination?
2)When is the best time to reset the WDT? at the end of the While(TRUE) loop?
3)My third question concerned one user interface for LCD display. My program will manage I2C and SCI communication will one user can tape on the keypad (interrupt on the keypad). The management of the display is then a bit tricky. Did someone have some experience with this?
Thank you! |
|