void delay(void)
{
// 1. disable WDT
rWTCON = 0;
// 2. Set WTCNT
rWTCNT = 500000/128; // 0.5 sec
// 3. Set WTDAT
rWTDAT = 0; // Initial Value : 0x8000
// 4. Set WTCON and Enable WDT (t_wdt : 128 us -> 1*128)
rWTCON = (PCLK/1000000)-1 << 8 | 1 << 5 | 3 << 3;
// 5. Polling WTCNT
while(rWTCNT);
// 6. Disable WDT
rWTCON = 0;
}
댓글