Watchdog Timer Reset
The watchdog timer provides a mechanism to reset the
processor in the case of undesirable code execution. The
watchdog timer is a hardware timer designed to be peri-
odically reset by the application software. If the software
operates correctly, the timer is reset before it reaches its
maximum count. However, if undesirable code execution
prevents a reset of the watchdog timer, the timer reaches
its maximum count and resets the processor.
The watchdog timer is controlled through two bits in the
WDCN register (WDCN[5:4]: WD[1:0]). Its timeout period
can be set to one of the four programmable intervals
ranging from 212 to 221 system clock (MOSC) periods
(0.409ms to 0.210s). The watchdog interrupt occurs at the
end of this timeout period, which is 512 MOSC clock peri-
ods, or approximately 50µs, before the reset. The reset
generated by the watchdog timer lasts for four system
clock cycles, which is 0.4µs. Software can determine if a
reset is caused by a watchdog timeout by checking the
watchdog timer reset flag (WTRF) in the WDCN register.
Execution resumes at location 8000h following a watch-
dog timer reset.
External Reset
Asserting RST low causes the device to enter the reset
state. The external reset function is described in the
DS4830 User’s Guide. Execution resumes at location
8000h after RST is released. The DAC and PWM outputs
are unchanged during execution of external reset.
Internal System Reset
The host can issue an I2C command (BBh) to reset the
communicating device. This reset has the same effect as
the external reset as far as the reset values of all registers
are concerned. Also, an internal system reset can occur
when the in-system programming is done (ROD = 1). The
DAC and PWM outputs are unchanged during execution
of an internal reset.
Further details are available in the DS4830 User’s Guide.
Programmable Timer
The device features two general-purpose programmable
timers. Various timing loops can be implemented using the
timers. Each general-purpose timer uses three SFRs. GTCN
is the general control register, GTV is the timer value regis-
ter, and GTC is the timer compare register.The timer can
be used in two modes: free-running mode and compare
mode with interrupts. Both are described in detail in the
DS4830 User’s Guide.
The functionality of the timers can be accessed through
three SFRs for each of the general-purpose timers. The
timer SFRs are accessed in module 0 and module 3.
Detailed information regarding the timer block can be
found in the DS4830 User’s Guide.
Hardware Multiplier
The hardware multiplier (multiply-accumulate, or MAC
module) is a very powerful tool, especially for applica-
tions that require heavy calculations. This multiplier
can execute the multiply or multiply-negate, or multiply-
accumulate or multiply-subtract operation for signed or
unsigned operands. The MAC module uses eight SFRs,
mapped as register 0h–05h and 08h–09h in module M3.
System Interrupts
Multiple interrupt sources are available to respond to
internal and external events. The microcontroller archi-
tecture uses a single interrupt vector (IV) and single inter-
rupt-service routine (ISR) design. For maximum flexibility,
interrupts can be enabled globally, individually, or by mod-
ule. When an interrupt condition occurs, its individual flag
is set, even if the interrupt source is disabled at the local,
module, or global level. Interrupt flags must be cleared
within the firmware-interrupt routine to avoid repeated
interrupts from the same source. Application software
must ensure a delay between the write to the flag and the
RETI instruction to allow time for the interrupt hardware
to remove the internal interrupt condition. Asynchronous
interrupt flags require a one-instruction delay and syn-
chronous interrupt flags require a two-instruction delay.
When an enabled interrupt is detected, execution jumps
to a user-programmable interrupt vector location. The IV
register defaults to 0000h on reset or power-up, so if it is
not changed to a different address, application firmware
must determine whether a jump to 0000h came from a
RST or interrupt source.
Once control has been transferred to the ISR, the inter-
rupt identification register (IIR) can be used to determine
if a system register or peripheral register was the source
of the interrupt. In addition to IIR, MIIR registers are
implemented to indicate which particular function under
a peripheral module has caused the interrupt. The device
contains six peripheral modules, M0 to M5. An MIIR reg-
ister is implemented in modules M1 and M2. The MIIRs
are 16-bit read-only registers and all of them default to
all zeros on system reset. Once the module that causes
the interrupt is singled out, it can then be interrogated
for the specific interrupt source and software can take
DS4830 Optical Microcontroller
www.maximintegrated.com Maxim Integrated
│
22