Pular para o conteúdo principal
Knowledgebase
Home
Renesas Brasil - Knowledgebase

How do I write to/read from the 16-bit timer in 16-bit units?

Latest Updated:12/01/2005

Question:

(Timer)   How do I write to/read from the 16-bit timer in 16-bit units?
At that time, is it necessary to disable interrupts? [2005/12/01]

Answer:

Since access by the user program is in 8-bit units, you need to access both the high and low timer registers.

Accessing the timer registers
<Writing>
Timer register (low) : latch to intermediate buffer
          ↓
Timer register (high) : latch to intermediate buffer; 16-bit data is latched from intermediate buffer or transferred to counter
<Reading >
Timer register (high) : transfer 16-bit data from counter to intermediate buffer and read from intermediate buffer
          ↓
Timer register (low) : read from intermediate buffer

As seen above, the presence of an intermediate buffer makes disabling interrupts during each timer register access unnecessary.

Reason for intermediate buffer
When accessing while the timer is in operation without an intermediate buffer, there is a difference in access time between the high and low timer registers, during which the timer counter may advance. If that happens, expected setting or read values will not be obtained. In order to avoid this sort of problem, the timer registers are accessed in 16-bit units via an intermediate buffer.

(#104916)

Suitable Products
3803H
3803L
3823
3858
38D2
38D5
7544
7546
7547
7548
7549