Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
даташитина PIC 12F683 .pdf
Скачиваний:
14
Добавлен:
02.02.2015
Размер:
3.06 Mб
Скачать

PIC12F683

12.6Watchdog Timer (WDT)

The WDT has the following features:

Operates from the LFINTOSC (31 kHz)

Contains a 16-bit prescaler

Shares an 8-bit prescaler with Timer0

Time-out period is from 1 ms to 268 seconds

Configuration bit and software controlled

WDT is cleared under certain conditions described in Table 12-7.

12.6.1WDT OSCILLATOR

The WDT derives its time base from the 31 kHz LFINTOSC. The LTS bit of the OSCCON register does not reflect that the LFINTOSC is enabled.

The value of WDTCON is ‘---0 1000’ on all Resets. This gives a nominal time base of 17 ms.

Note: When the Oscillator Start-up Timer (OST) is invoked, the WDT is held in Reset, because the WDT Ripple Counter is used by the OST to perform the oscillator delay count. When the OST count has expired, the WDT will begin counting (if enabled).

12.6.2WDT CONTROL

The WDTE bit is located in the Configuration Word register. When set, the WDT runs continuously.

When the WDTE bit in the Configuration Word register is set, the SWDTEN bit of the WDTCON register has no effect. If WDTE is clear, then the SWDTEN bit can be used to enable and disable the WDT. Setting the bit will enable it and clearing the bit will disable it.

The PSA and PS<2:0> bits of the OPTION register have the same function as in previous versions of the PIC12F683 Family of microcontrollers. See

Section 5.0 “Timer0 Module” for more information.

FIGURE 12-9:

WATCHDOG TIMER BLOCK DIAGRAM

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

From Timer0 Clock Source

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

Prescaler(1)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

16-bit WDT Prescaler

 

 

 

 

 

 

 

 

 

 

8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PSA

 

 

 

 

 

 

 

 

PS<2:0>

31 kHz

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LFINTOSC Clock

 

 

 

 

 

 

 

WDTPS<3:0>

 

 

 

 

 

 

 

0

 

 

 

1

 

 

 

 

To Timer0

 

 

 

 

 

 

 

 

 

 

WDTE from Configuration Word register

 

 

 

 

 

 

 

 

 

 

 

 

 

PSA

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SWDTEN from WDTCON

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

WDT Time-out

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note 1: This is the shared Timer0/WDT prescaler. See Section 5.0 “Timer0 Module” for more information.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TABLE 12-7: WDT STATUS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Conditions

 

 

 

 

 

 

 

 

 

 

WDT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

WDTE = 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CLRWDT Command

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Cleared

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Oscillator Fail Detected

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Exit Sleep + System Clock = T1OSC, EXTRC, INTRC, EXTCLK

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Exit Sleep + System Clock = XT, HS, LP

 

 

 

 

 

 

Cleared until the end of OST

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DS41211D-page 96

2007 Microchip Technology Inc.

PIC12F683

REGISTER 12-2: WDTCON: WATCHDOG TIMER CONTROL REGISTER

U-0

U-0

U-0

R/W-0

R/W-1

R/W-0

R/W-0

R/W-0

 

 

 

 

 

 

 

 

 

 

WDTPS3

WDTPS2

WDTPS1

WDTPS0

SWDTEN

bit 7

 

 

 

 

 

 

 

bit 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Legend:

 

 

 

 

 

 

 

 

R = Readable bit

W = Writable bit

 

U = Unimplemented bit, read as ‘0’

 

-n = Value at POR

‘1’ = Bit is set

 

‘0’ = Bit is cleared

x = Bit is unknown

 

 

 

 

 

 

 

 

 

bit 7-5

Unimplemented: Read as ‘0

 

 

 

 

 

bit 4-1

WDTPS<3:0>: Watchdog Timer Period Select bits

 

 

 

Bit Value = Prescale Rate

 

0000

= 1:32

 

0001

= 1:64

 

0010

= 1:128

 

0011

= 1:256

 

0100

= 1:512 (Reset value)

 

0101

= 1:1024

 

0110

= 1:2048

 

0111

= 1:4096

 

1000

= 1:8192

 

1001

= 1:16384

 

1010

= 1:32768

 

1011

= 1:65536

 

1100

= Reserved

 

1101

= Reserved

 

1110

= Reserved

 

1111

= Reserved

bit 0

SWDTEN: Software Enable or Disable the Watchdog Timer(1)

 

1 = WDT is turned on

 

0 = WDT is turned off (Reset value)

Note 1:

If WDTE Configuration bit = 1, then WDT is always enabled, irrespective of this control bit. If WDTE

 

Configuration bit = 0, then it is possible to turn WDT on/off with this control bit.

TABLE 12-8: SUMMARY OF REGISTERS ASSOCIATED WITH WATCHDOG TIMER

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Value on

Value on

Name

 

 

Bit 7

Bit 6

Bit 5

 

Bit 4

Bit 3

Bit 2

Bit 1

Bit 0

all other

 

 

 

POR, BOR

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Resets

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

WDTCON

 

 

 

WDTPS3

WDTPS2

WSTPS1

WDTPS0

SWDTEN

---0 1000

---0 1000

OPTION_REG

 

 

 

INTEDG

T0CS

 

T0SE

PSA

PS2

PS1

PS0

 

 

 

GPPU

1111 1111

1111 1111

CONFIG

 

 

 

 

 

 

 

MCLRE

 

 

 

WDTE

FOSC2

FOSC1

FOSC0

 

 

CPD

CP

PWRTE

Legend:

Shaded cells are not used by the Watchdog Timer.

 

 

 

 

 

Note 1:

See Register 12-1 for operation of all Configuration Word register bits.

 

 

 

2007 Microchip Technology Inc.

DS41211D-page 97

PIC12F683

12.7Power-Down Mode (Sleep)

The Power-down mode is entered by executing a SLEEP instruction.

If the Watchdog Timer is enabled:

WDT will be cleared but keeps running.

PD bit in the STATUS register is cleared.

TO bit is set.

Oscillator driver is turned off.

I/O ports maintain the status they had before SLEEP was executed (driving high, low or high-impedance).

For lowest current consumption in this mode, all I/O pins should be either at VDD or VSS, with no external circuitry drawing current from the I/O pin and the comparators and CVREF should be disabled. I/O pins that are high-impedance inputs should be pulled high or low externally to avoid switching currents caused by floating inputs. The T0CKI input should also be at VDD or VSS for lowest current consumption. The contribution from on-chip pull-ups on GPIO should be considered.

The MCLR pin must be at a logic high level.

Note: It should be noted that a Reset generated by a WDT time-out does not drive MCLR pin low.

12.7.1WAKE-UP FROM SLEEP

The device can wake-up from Sleep through one of the following events:

1.External Reset input on MCLR pin.

2.Watchdog Timer wake-up (if WDT was enabled).

3.Interrupt from GP2/INT pin, GPIO change or a peripheral interrupt.

The first event will cause a device Reset. The two latter events are considered a continuation of program execution. The TO and PD bits in the STATUS register can be used to determine the cause of a device Reset. The PD bit, which is set on power-up, is cleared when Sleep is invoked. TO bit is cleared if WDT wake-up occurred.

The following peripheral interrupts can wake the device from Sleep:

1.Timer1 interrupt. Timer1 must be operating as an asynchronous counter.

2.ECCP Capture mode interrupt.

3.A/D conversion (when A/D clock source is FRC).

4.EEPROM write operation completion.

5.Comparator output changes state.

6.Interrupt-on-change.

7.External Interrupt from INT pin.

Other peripherals cannot generate interrupts since during Sleep, no on-chip clocks are present.

When the SLEEP instruction is being executed, the next instruction (PC + 1) is prefetched. For the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled). Wake-up occurs regardless of the state of the GIE bit. If the GIE bit is clear (disabled), the device continues execution at the instruction after the SLEEP instruction. If the GIE bit is set (enabled), the device executes the instruction after the SLEEP instruction, then branches to the interrupt address (0004h). In cases where the execution of the instruction following SLEEP is not desirable, the user should have a NOP after the SLEEP instruction.

Note: If the global interrupts are disabled (GIE is cleared) and any interrupt source has both its interrupt enable bit and the corresponding interrupt flag bits set, the device will immediately wake-up from Sleep.

The WDT is cleared when the device wakes up from Sleep, regardless of the source of wake-up.

12.7.2WAKE-UP USING INTERRUPTS

When global interrupts are disabled (GIE cleared) and any interrupt source has both its interrupt enable bit and interrupt flag bit set, one of the following will occur:

If the interrupt occurs before the execution of a SLEEP instruction, the SLEEP instruction will complete as a NOP. Therefore, the WDT and WDT prescaler and postscaler (if enabled) will not be cleared, the TO bit will not be set and the PD bit will not be cleared.

If the interrupt occurs during or after the execution of a SLEEP instruction, the device will Immediately wake-up from Sleep. The SLEEP instruction is executed. Therefore, the WDT and WDT prescaler and postscaler (if enabled) will be cleared, the TO bit will be set and the PD bit will be cleared.

Even if the flag bits were checked before executing a SLEEP instruction, it may be possible for flag bits to become set before the SLEEP instruction completes. To determine whether a SLEEP instruction executed, test the PD bit. If the PD bit is set, the SLEEP instruction was executed as a NOP.

To ensure that the WDT is cleared, a CLRWDT instruction should be executed before a SLEEP instruction. See Figure 12-10 for more details.

DS41211D-page 98

2007 Microchip Technology Inc.