Friday, March 1, 2013
/////////////////////////////////////////////////////////////////////////
//// ////
//// This program demonstartes the watchdog timer. If the user ////
//// does not hit a key in the set amount of time, the processor ////
//// restarts, and tells the user why it restarted. ////
//// ////
//// Jumpers: ////
//// PCH pin C7 to RS232 RX, pin C6 to RS232 TX ////
//// PCD none ////
//// ////
//// This example will work with the PCD compiler. ////
//// The following conditional compilation lines are used to ////
//// include a valid device for each compiler. Change the device, ////
//// clock and RS232 pins for your hardware if needed. ////
/////////////////////////////////////////////////////////////////////////
#ifndef __PCD__
#error This example is only for dsPIC/PIC24 devices
#endif
#include <30f5011 .h="">30f5011>
#fuses HS,NOPROTECT,WDT,WPSB1,WPSA512
#use delay(clock=20000000)
#use rs232(baud=9200, UART1)
main() {
switch ( restart_cause() )
{
case RESTART_WATCHDOG:
{
printf("rnRestarted processor because of watchdog timeout!rn");
break;
}
case RESTART_POWER_UP:
{
printf("rnNormal power up!rn");
break;
}
}
setup_wdt(WDT_ON);
while(TRUE)
{
restart_wdt();
printf("Hit any key to avoid a watchdog timeout.rn");
getc();
}
}
Currently have 0 comentarios: