70
IB822 Series
User’s Manual
bTime = strtol (argv[1], endptr, 10);
printf("System will reset after %d seconds\n", bTime);
if (bTime)
{
EnableWDT(bTime); }
else
{
DisableWDT(); }
return 0;
}
//---------------------------------------------------------------------------
void EnableWDT(int interval)
{
unsigned char bBuf;
bBuf = Get_F81964_Reg(0x2B);
bBuf &= (~0x20);
Set_F81964_Reg(0x2B, bBuf);
//Enable WDTO
Set_F81964_LD(0x07);
//switch to logic device 7
Set_F81964_Reg(0x30, 0x01);
//enable timer
bBuf = Get_F81964_Reg(0xF5);
bBuf &= (~0x0F);
bBuf |= 0x52;
Set_F81964_Reg(0xF5, bBuf);
//count mode is second
Set_F81964_Reg(0xF6, interval);
//set timer
bBuf = Get_F81964_Reg(0xFA);
bBuf |= 0x01;
Set_F81964_Reg(0xFA, bBuf);
//enable WDTO output
bBuf = Get_F81964_Reg(0xF5);
bBuf |= 0x20;
Set_F81964_Reg(0xF5, bBuf);
//start counting
}
//---------------------------------------------------------------------------
void DisableWDT(void)
{
unsigned char bBuf;
Set_F81964_LD(0x07);
//switch to logic device 7
bBuf = Get_F81964_Reg(0xFA);
bBuf &= ~0x01;
Set_F81964_Reg(0xFA, bBuf);
//disable WDTO output
bBuf = Get_F81964_Reg(0xF5);
bBuf &= ~0x20;
bBuf |= 0x40;
Set_F81964_Reg(0xF5, bBuf);
//disable WDT
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY