EM6607 EM Microelectronic, EM6607 Datasheet - Page 21

no-image

EM6607

Manufacturer Part Number
EM6607
Description
Ultra-low power microcontroller
Manufacturer
EM Microelectronic
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
EM6607TP16B
Quantity:
20 000
Part Number:
EM6607TP16B
Manufacturer:
NUVOTON
Quantity:
1 200
R
EM6607
9
Timer/Event Counter
The EM6607 has a built-in 8 bit countdown auto-reload Timer/Event counter that takes an input from either the prescaler or
Port PA3. If the Timer/Event counter counts down to $00 the interrupt request flag IntTim is set to 1. If the Timer/Event
counter interrupt is enabled by setting the mask flag MTimC set to 1, then an interrupt request is generated to the CPU. See
also section 9. If used as an event counter, pulses from the PA3 terminal are input to the event counter. See figure 10 and
tables 28 and 29 on the next page for PA3 source selection (debounced or not, Rising/Falling edge). By default rising and
debounced PA3 input is selected.
The timer control register TimCtr selects the auto-reload function and input clock source. At initial RESET this bit is cleared
to 0 selecting no auto-reload. To enable auto-reload TimAuto must be set to 1. The Timer/Event counter can be enabled or
disabled by writing to the TIMen control bit in the BEEP register. At initial RESET it is cleared to 0. When used as timer, it is
initialised according to the data written into the timer load/status registers LTimLS (low 4 bits) and HTimLS (high four bits).
The timer starts to count down as soon as the LTimLS value is written. When loading the Timer/Event counter registers the
correct order must be respected: First, write either the control register TimCtr or the high data nibble HTimLS. The last
register written should be the low data nibble LTimLS. During count down, the timer can always be reloaded with a new
value, but the high four bits will only be accepted during the write of the low four bits.
In the case of the auto-reload function, the timer is initialised with the value of the load registers LTimLS and HTimLS.
Counting with the auto-reload function is only enabled during the write to the low four bits, (writing TimAuto to 1 does not
start the timer counting down with the last value in the timer load registers but it waits until a new LTimLS load). The timer
counting to $00 generates a timer interrupt event and reloads the registers before starting to count down again. To stop the
timer at any time, a write of $00 can be made to the timer load registers, this sets the TimAuto flag to 0. If the timer is
stopped by writing the TimEn bit to 0, the timer status can be read. The current timer status can be always obtained by
reading the timer registers LTimLS and HTimLS. For proper operation read ordering should be respected such that the first
read should be of the LTimLS register followed by the HTimLS register. Example: To have continous 1sec timer IRQ with
128Hz one has to write 128dec (80hex) in Timer registers with auto-reload.
Using the Timer/Event Counter as the event counter allows several possibilities:
1.) Firstly, load the number of PA3 input edges expected into the load registers and then generate an interrupt request
when counter reaches $00.
2.) The second is to write timer/counter to $FF, then select the event counter mode, and lastly enable the event counter by
setting the TimEn bit to 1, which starts the count.
Because the counter counts down, a binary complement has to be done in order to get the number of events at the PA3
input.
3) Another option is to use the Timer/Event counter in conjunction with the prescaler interrupt, such that it is possible to
count the number of the events during two consecutive 32Hz, 8Hz or 1Hz prescaler interrupts.
Figure 12.
Timer / Event Counter
Copyright © 2005, EM Microelectronic-Marin SA
21
www.emmicroelectronic.com

Related parts for EM6607