17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Functional Overview<br />

WDT or Watch Dog Timer<br />

Different chips provide different options to enable/disable or configure the WDT.<br />

Relevant Functions:<br />

setup_wdt()<br />

restart_wdt()<br />

Enables/disables the wdt or sets the prescalar.<br />

Restarts the wdt, if wdt is enables this must be periodically called<br />

to prevent a timeout reset.<br />

For <strong>PCB</strong>/<strong>PCM</strong> chips it is enabled/disabled using WDT or NOWDT fuses whereas on <strong>PCH</strong><br />

device it is done using the setup_wdt function.<br />

The timeout time for <strong>PCB</strong>/<strong>PCM</strong> chips are set using the setup_wdt function and on <strong>PCH</strong> using<br />

fuses like WDT16, WDT256 etc.<br />

RESTART_WDT when specified in #USE DELAY, #USE I2C and #USE RS232 statements like<br />

this #USE DELAY(clock=20000000, restart_wdt) will cause the wdt to restart if it times out<br />

during the delay or I2C_READ or GETC.<br />

Relevant Preprocessor:<br />

#FUSES WDT/NOWDT<br />

#FUSES WDT16<br />

Enabled/Disables wdt in <strong>PCB</strong>/<strong>PCM</strong> devices<br />

Sets ups the timeout time in <strong>PCH</strong> devices<br />

Relevant Interrupts:<br />

None<br />

Relevant Include Files:<br />

None, all functions built-in<br />

Relevant getenv() parameters:<br />

None<br />

Example Code:<br />

For PIC16F877<br />

#fuses wdt<br />

setup_wdt(WDT_2304MS);<br />

while(true){<br />

restart_wdt();<br />

perform_activity();<br />

}<br />

For PIC18F452<br />

#fuse WDT1<br />

setup_wdt(WDT_ON);<br />

while(true){<br />

restart_wdt();<br />

79

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!