16 16-BIT AUDIO PWM TIMER (T16P)
S1C33L26 TECHNICAL MANUAL
Seiko Epson Corporation
16-5
Control and T16P Operations
16.4
Resetting T16P
16.4.1
Writing 1 to PRESET/T16P_CTL register resets T16P. The following operations are performed when PRESET is
set to 1.
• The counter (CNT_DATA[15:0]/T16P_CNT_DATA register) is reset to 0x0.
• The B match counter is reset to 0x0.
• The initial volume level (VOLSEL[6:0]/T16P_VOL_CTL register) is loaded into the volume control circuit.
• The compare A and B buffers/registers (CMPA[15:0]/T16P_A register, CMPB[15:0]/T16P_B register) are reset
to 0x0.
• The buffer empty flag (BUFEF/T16P_INT register) is set to 1. (No interrupt occurs.)
• All other interrupt flags are reset to 0 and interrupt requests are canceled.
• DMA request is canceled if it has been issued.
• The PWM outputs go to the initial output level set by INITOL/T16P_CTL register.
Note: Be sure to reset T16P before the GPIO pins are switched to the PWM_H and PWM_L pins, and
before setting PRUN/T16P_RUN register to 1 to start T16P.
Run/Stop Control
16.4.2
To start T16P, write 1 to PRUN/T16P_RUN register.
T16P must be reset (write 1 to PRESET/T16P_CTL register) before writing 1 to PRUN. Resetting the T16P sets the
buffer empty flag to 1, but neither an interrupt request nor a DMA request is issued at this point even if the buffer
empty interrupt is enabled. Writing 1 to PRUN enables T16P to issue buffer empty interrupts and DMA requests, so
that the first audio data can be sent to the buffer in the interrupt handler routine or DMA.
Note: Writing 1 to PRUN does not actually start T16P, because the buffer is still empty. T16P will start
after the buffer is filled by an interrupt or DMA.
To stop T16P being run, write 0 to PRUN. The compare data buffers/registers and counter retain the value at stop.
The PWM output is fixed at the level set by INITOL. Note that T16P may not stop counting until B match condi-
tions occur (BCNT[3:0] + 1) times.
Setting Compare Data
16.4.3
Compare A buffer
The compare A buffer (CMPA[15:0]/T16P_A register) is used to specify output pulse widths (duty cycles). Set
output audio data to this buffer. The buffer data is loaded to the compare A register when the timer starts count-
ing or when a B match occurs specified number of times, and is compared with the counter value. The output
signal level is inverted at the beginning of a pulse period and when the counter reaches the compare data stored
in the compare A register. This operation converts audio data set to the compare A buffer into a pulse width.
When the data written to the compare A buffer is loaded to the compare A register, the buffer empty interrupt
flag (BUFEF/T16P_INT register) is set to 1 and an interrupt occurs if buffer empty interrupts are enabled. Also
this cause of interrupt can invoke a DMA transfer. By using this interrupt or DMA transfer, the next output data
can be set to the compare A buffer.
When the counter reaches the compare A data, the A match interrupt flag (INTAF/T16P_INT register) is set to
1 and an interrupt occurs if A match interrupts are enabled. This type of interrupts does not occur in split mode
or when 8-bit PCM data resolution is selected.
The pulse width set by compare A data is as follows:
In normal comparison mode (SELFM/T16P_CTL register = 0)
Output pulse width = CMPA
×
Count clock cycle
(CMPA: CMPA[15:0] in normal mode, CMPA[15:n] or CMPA[(n-1):0] in split mode)
In fine mode (SELFM = 1)
Output pulse width = CMPA
×
PCLK1 cycle
×
1/2
(CMPA: CMPA[15:0] in normal mode, CMPA[15:n] or CMPA[(n-1):0] in split mode)
8-bit audio data should be written to CMPA[15:8] in 8-bit size.