f133 User Manual v1.0
f133 User Manual v1.0
User Manual
Revision 1.0
May 24, 2021
Confidential
Revision History
Revision Date Author Description
1.0 May 24, 2021 AWA0330 Initial release version
Contents
Revision History ....................................................................................................................................................................i
Contents ............................................................................................................................................................................... ii
Contents ...............................................................................................................................................................................3
Contents ............................................................................................................................................................................ 24
Figures ............................................................................................................................................................................... 27
Tables ................................................................................................................................................................................ 29
3 System ....................................................................................................................................................................... 30
7 Memory................................................................................................................................................................... 558
The symbols that may be found in this document are defined as follows.
Symbol Description
Indicates potential risk of injury or death exists if the instructions are not obeyed.
WARNING
Indicates potential risk of equipment damage, data loss, performance
CAUTION degradation, or unexpected results exists if the instructions are not obeyed.
Provides additional information to emphasize or supplement important points of
NOTE the main text.
The table content conventions that may be found in this document are defined as follows.
Symbol Description
/ The cell is blank.
If other column value in a bit or multiple bits row is “/”, that this bit or these multiple bits are unused.
If the default value of a bit or multiple bits is “UDF”, that the default value is undefined.
The register attributes that may be found in this document are defined as follows.
Symbol Description
R Read Only
R/W Read/Write
Read/Write-Automatic-Clear, clear the bit automatically when the operation of
R/WAC
complete. Writing 0 has no effect
R/WC Read/Write-Clear
R/W0C Read/Write 0 to Clear. Writing 1 has no effect
R/W1C Read/Write 1 to Clear. Writing 0 has no effect
R/W1S Read/Write 1 to Set. Writing 0 has no effect
W Write Only
The expressions of data capacity, frequency, and data rate are described as follows.
Contents
2 Product Description .....................................................................................................................................................4
2 Product Description
2.1 Overview
F133 is an advanced application processor designed for the video decoding platform. It integrates a 64-bit
processor with RISC CPU instruction architecture to provide the most efficient computing power. F133 supports
full format decoding such as H.265, H.264, MPEG-1/2/4, JPEG, VC1, and so on. And the independent hardware
encoder can encode in JPEG or MJPEG. Integrated multi ADCs/DACs and I2S/PCM/DMIC/OWA audio interfaces
can work seamlessly with the CPU to accelerate multimedia algorithms and provide the perfect voice
interaction solution. F133 supports rich display output interfaces to meet the requirements of the screen
display in differentiated markets. F133 can be used in network video machines, advertising machines, digital
photo frames, car MP5, and so on.
The F133 is configured with different sets of features in different devices. Table 2-1 shows the feature
differences across different devices.
2.2 Features
RISC CPU
On-chip memory
- SD card
- eMMC
Supports GPIO pin and eFuse module to select the boot media type
2.2.2.2 SDRAM
2.2.2.3 SMHC
The SMHC0 controls the devices that comply with the protocol Secure Digital Memory (SD mem-version
3.0)
The SMHC1 controls the device that complies with the protocol Secure Digital I/O (SDIO-version 3.0)
The SMHC2 controls the device that complies with the protocol Multimedia Card (eMMC-version 5.0)
Maximum performance:
Video decoding
- H.263 BP up to 1080p@60fps
- Xvid up to 1080p@60fps
- MJPEG up to 1080p@30fps
Video encoding
- JPEG/MJPEG up to 1080p@60fps
Supports two alpha blending channels for main display and one channel for aux display
Supports four overlay layers in each channel, and has an independent scaler
Supports multiple video formats 4:2:0, 4:2:2, 4:1:1 and multiple pixel formats (8/16/24/32 bits graphics
layer)
Supports 32-phase 8-tap horizontal anti-alias filter and 32-phase 4-tap vertical anti-alias filter
Supports horizontal and vertical flip, clockwise 0/90/180/270 degree rotate for normal buffer
Supports horizontal flip, clockwise 0/90/270 degree rotate for LBC buffer
Supports 4-lane MIPI DSI, up to 1280 x 720@60fps and 1920 x 1200@60fps resolution
Supports non-burst mode with sync pulse/sync event and burst mode
Supports pixel format: RGB888, RGB666, RGB666 loosely packed and RGB565
2.2.7.1 Timer
The timer module implements the timing and counting functions, which includes timer0, timer1,
watchdog, and audio video synchronization (AVS)
The timer0/timer1 is a 32-bit down counter. The timer0 and timer1 are completely consistent
The watchdog is used to transmit a reset signal to reset the entire system when an exception occurs in
the system
The AVS is used to synchronize the audio and video. The AVS sub-block includes AVS0 and AVS1, which
are completely consistent
The HSTimer module consists of HSTimer0 and HSTimer1. HSTimer0 and HSTimer1 are down counters that
implement timing and counting functions. They are completely consistent.
The clock source is synchronized with AHB0 clock, much more accurate than other timers
The interrupt can be configured as machine mode and super user mode
Up to 256 interrupt source sampling, supporting level interrupt and pulse interrupt
Maintains independently the interrupt enable for each interrupt mode (machine/super user)
Maintains independently the interrupt threshold for each interrupt mode (machine/super user)
2.2.7.4 DMAC
Up to 16-ch DMA
Provides 32 peripheral DMA requests for data reading and 32 peripheral DMA requests for data writing
8 PLLs
Supports one external 24 MHz DCXO and one external 32.768 kHz oscillator
Supports software-controlled clock gating and software-controlled reset for corresponding modules
Temperature accuracy: ±3°C from 0°C to +100°C, ±5°C from -25°C to +125°C
LDOA: 1.8 V power output, LDOB: 1.35 V/1.5 V/1.8 V power output
2.2.7.8 RTC
Provides a 16-bit counter for counting day, 5-bit counter for counting hour, 6-bit counter for counting
minute, 6-bit counter for counting second
Supports timing alarm, and generates interrupt and wakeup the external devices
Supports 2 levels TLB (level1 TLB for special using, and level2 TLB for sharing)
- One differential microphone input: MICIN3P/3N, or one single-end microphone input: MICIN3P
Supports Dynamic Range Controller adjusting the DAC playback and ADC recording
One 128x20-bits FIFO for DAC data transmit, one 128x20-bits FIFO for ADC data receive
2.2.8.2 I2S/PCM
Two I2S/PCM external interfaces (I2S1, I2S2) for connecting external power amplifier and MIC ADC
- Left-justified, Right-justified, PCM mode, and Time Division Multiplexing (TDM) format
- Programmable PCM frame width: 1 BCLK width (short frame) and 2 BCLKs width (long frame)
- 128 depth x 32-bit width TXFIFO and 64 depth x 32-bit width RXFIFO
- Clock up to 24.576 MHz Data Output of I2S/PCM in Master mode (Only if the IO PAD and Peripheral
I2S/PCM satisfy Timing Parameters)
- Up to 16 channels (fs = 48 kHz) which has adjustable width from 8-bit to 32-bit
2.2.8.3 DMIC
- IEC-61937 uses the IEC-60958 series for the conveying of non-linear PCM bit streams, each sub-frame
transmits 16-bit
- One 128×24bits TXFIFO and one 64×24bits RXFIFO for audio data transfer
- The clock of TX function includes 24.576 MHz and 22.579 MHz frequency
Supports Symmetrical algorithm for encryption and decryption: AES, DES, TDES
- Supports ECB, CBC, CTS, CTR, CFB, OFB mode for AES
One USB 2.0 DRD (USB0), with integrated USB 2.0 analog PHY
- Compatible with Enhanced Host Controller Interface (EHCI) Specification, Version 1.0
- Compatible with Open Host Controller Interface (OHCI) Specification, Version 1.0a
- Supports High-Speed (HS, 480 Mbit/s), Full-Speed (FS, 12 Mbit/s), and Low-Speed (LS, 1.5 Mbit/s)
- Supports only 1 USB Root port shared between EHCI and OHCI
- Up to 10 user-configurable endpoints (EP1+, EP1-, EP2+, EP2-, EP3+, EP3-, EP4+, EP4-, EP5+, EP5-) for
Bulk transfer, Isochronous transfer and Interrupt transfer
Supports point-to-point and point-to-multipoint transfer in both Host and Peripheral modes
One USB 2.0 HOST (USB1), with integrated USB 2.0 analog PHY
- Compatible with Enhanced Host Controller Interface (EHCI) Specification, Version 1.0
- Compatible with Open Host Controller Interface (OHCI) Specification, Version 1.0a
- Supports High-Speed (HS, 480 Mbit/s), Full-Speed (FS, 12 Mbit/s) and Low-Speed (LS, 1.5 Mbit/s)
Device
- Supports only 1 USB Root port shared between EHCI and OHCI
2.2.10.3 EMAC
Provides the management data input/output (MDIO) interface for PHY device configuration and
management with configurable clock frequencies
Programmable frame length to support Standard or Jumbo Ethernet frames with sizes up to 16 KB
- Descriptor architecture, allowing large blocks of data transfer with minimum CPU intervention; each
descriptor can transfer up to 4 KB of data
- Comprehensive status reporting for normal operation and transfers with errors
2.2.10.4 UART
- Each of them is 256 bytes (For UART1, UART2, UART3, UART4, and UART5)
Supports standard mode (up to 100 kbit/s) and fast mode (up to 400 kbit/s)
The TWI controller includes one TWI engine and one TWI driver. And the TWI driver supports packet
transmission and DMA mode when TWI works in master mode
The SPI0 only supports SPI mode; The SPI1 supports SPI mode and display bus interface (DBI) mode
SPI mode:
- Master/slave configurable
- Mode0 to Mode3 are supported for both transmit and receive operations
- 8-bit wide by 64-entry FIFO for both transmit and receive data
- Polarity and phase of the Chip Select (SPI-CS) and SPI Clock (SPI-CLK) are configurable
DBI mode:
- Maximum resolution of RGB888 240 x 320@60Hz or 320 x 480@30Hz with dual data lane
2.2.10.9 PWM
- Supports PWM pulse mode output, and the pulse number is configurable
- PWM01 pair (PWM0 + PWM1), PWM23 pair (PWM2 + PWM3), PWM45 pair (PWM4 + PWM5),
PWM67 pair (PWM6 + PWM7)
- Supports any plural channels to form a group, and output the same duty-cycle pulse
- In group mode, the relative phase of the output waveform for each channel is configurable
- Supports rising edge detection and falling edge detection for input waveform pulse
Supports three operation modes: single conversion mode, continuous conversion mode, burst conversion
mode
2.2.10.12 LEDC
LEDC data supports DMA configuration mode and CPU configuration mode
2.2.11 Package
eLQFP128, 14 mm x 14 mm x 1.4 mm
I-cache 32 KB D-cache 32 KB
USB2.0 HOST
Parallel CSI
SDIO3.0
Video Output Display Engine Internal System SPI x2
(Supports SPI Nand/Nor Flash)
MIPI DSI DE CCU
TWI x4
RGB DI PLIC
UART x6
DMA
Dual link LVDS G2D
100M/1000M EMAC
Thermal Sensor
CVBS OUT Video Engine
Timer GPADC (1-ch)
Video Decoding
Audio H.265/H.264
High Speed Timer TPADC (4-ch)
Audio Codec Video Encoding
JPEG/MJPEG IOMMU PWM (8-ch)
I2S/PCM x2
Memory Security System LEDC
SPEAKER SPEAKER
WIFI/BT
HP HP
(XR819s) SDIO1 USB0 USB1 TPADC GPADC0
OUTL OUTR
UART1 LINEINL/R
Contents
3 System ....................................................................................................................................................................... 30
Figures
Figure 3-1 RISC System Block Diagram................................................................................................................................ 34
Tables
Table 3-1 PLL Typical Application ........................................................................................................................................ 48
Table 3-14 Correspondence Relation between Master and Module ............................................................................... 247
3 System
3.2.1 Overview
The RISC system includes RISC IP core and related peripheral devices (RISC_CFG, RISC_TIMESTAMP, Watchdog,
PSENSOR, BROM, and so on), which are interconnected by BUS Matrix.
Instruction and data cache of the first level Harvard, 32 KB I-cache + 32 KB D-cache, 64 B cacheline
Instruction high-cache can configure parity, and data high-cache can configure ECC or parity
Two-level TLB memory management unit to realize the virtual-real address translation and memory
management
L4_CONN
AHB 32
AXI 128
0x4000_0000
AXI bridge AXI2MBUS GMB_TOP
0x0 128
X2H_AXI
X2H_AHB
AHB 32
AHB Matrix
AHB2APB
MSGBOX BROM(64KB)
RISCV_CFG WDG
GRAYENC TIMERSTAMP
mclk 400MHz
DDRPHY
The 0x0004 register and 0x0008 register are grouped into a 40-bit address which is the running PC address
after RISC releases reset. Before releasing reset, this register should be configured. This register does support
dynamic configuration.
RF1P_CFG
7:0 R/W 0x13
RF1P Configuration
ROM_CFG
7:0 R/W 0x02
ROM Configuration
The 0x0024 to 0x0034 registers corresponds to the wakeup enable bits of 160 interrupts. These wakeup enable
bits are disabled by default. When some interrupt needs to be waken-up, the corresponding bit needs to be
set to 1.
The 0x0024 to 0x0034 registers corresponds to the wakeup enable bits of 160 interrupts. These wakeup enable
bits are disabled by default. When some interrupt needs to be waken-up, the corresponding bit needs to be
set to 1.
The 0x0024 to 0x0034 registers corresponds to the wakeup enable bits of 160 interrupts. These wakeup enable
bits are disabled by default. When some interrupt needs to be waken-up, the corresponding bit needs to be
set to 1.
The 0x0024 to 0x0034 registers corresponds to the wakeup enable bits of 160 interrupts. These wakeup enable
bits are disabled by default. When some interrupt needs to be waken-up, the corresponding bit needs to be
set to 1.
The 0x0024 to 0x0034 registers corresponds to the wakeup enable bits of 160 interrupts. These wakeup enable
bits are disabled by default. When some interrupt needs to be waken-up, the corresponding bit needs to be
set to 1.
3.2.4.11 0x0040 Timestamp Test Mode Select Register (Default Value: 0x0000_0000)
3.2.4.21 0x0104 RISC AXI PMU Control Register (Default Value: 0x0000_0000)
3.2.4.22 0x0108 RISC AXI PMU Period Register (Default Value: 0x0000_0000)
3.2.4.23 0x010C RISC AXI PMU Read Latency Register (Default Value: 0x0000_0000)
3.2.4.24 0x0110 RISC AXI PMU Write Latency Register (Default Value: 0x0000_0000)
3.2.4.25 0x0114 RISC AXI PMU Read Request Register (Default Value: 0x0000_0000)
3.2.4.26 0x0118 RISC AXI PMU Write Request Register (Default Value: 0x0000_0000)
3.2.4.27 0x011C RISC AXI PMU Read Bandwidth Register (Default Value: 0x0000_0000)
3.2.4.28 0x0120 RISC AXI PMU Write Bandwidth Register (Default Value: 0x0000_0000)
3.3.1 Overview
The clock controller unit (CCU) controls the PLL configurations and most of the clock generation, division,
distribution, synchronization, and gating. The input signals of the CCU include the external clock for the
reference frequency (24 MHz). The outputs from the CCU are mostly clocks to other blocks in the system.
8 PLLs
The following figure shows the functional block diagram of the CCU.
APB0
REG
CCU
Gating
BGR
Reset
DCXO 24 MHz
PLLs ...
CLK0 ...
CLK1 LEDC_CLK
... MUX GATE DIV
CPUX_CLK
CLKn
RC 16 MHz
The system buses include advanced high-performance buses (AHBs), advanced peripheral buses (APBs), and
MBUS.
All devices mounted at the bus should use the related bus clocks, and the gating signals for the bus are from
the CCU module.
The following figure shows the diagram of the System Bus Tree.
AHB_DECODE(SLV0)—AHB0
AHB_DECODE(SLV1)—AHB1
AHB_DECODE(SLV2)—AHB2
APB_DECODE(SLV0)—APB0
APB_DECODE(SLV1)—APB1
-Timer -SID
-GPIO -DCU
APB1 clock -PWM -GIC
-CE -SMHC
-CCU -camera_subsys
-UART -MSI -SPI
MBUS clock -Audio_subsys -video_subsy
-TWI -------------------- -USBDRD
-INTC -display_subsys STBY_subsystem
-CPU_SUBSYS_CFG -EMAC
-OWA -RISC_subsys
-IR_TX -TSTAMP_STU
-GPADC -TSTAMP_CTRL
-IDC SYSRTC
-C0_CPUx_CFG (AON)
BROM -C0_CPUx_mbist
AHB_DECODER
Display_subsys
TEST_SYS USB0
Camera_ SMHC0
RISC_subsys USB1
Video_ subsys DE (SDCard) SRAM
I/D cache: subsys DI DMAC SHMC1 CE (32 KB)
DCU SMHC2
32 KB G2D (SDIO)
D130 CVBSIN/ RBG/LVDS/DSI/ (eMMC)
BIST CSI CVBSOUT EMAC
Master
MBUS MBUS MBUS MBUS AHB AHB MBUS
(MBUS:64bits) (MBUS:64bits)
(MBUS:64bits) (MBUS:64bits)
L3_MAIN_CONNECT(MSI)
SMC
HIF_SYNC
(HIF:128bits)
DDRC
DDR_PHY
normal mux
cpupll peripll1x clkdiv3/3 peripll_div syscpus
ddrpll
vepll
clk mux video0pll 4x/2x/1x
peripll1x GATE div24 GATE emac_clck25m_fanout PAD
video1pll 4x/2x/1x
audio0pll8x
glitch free mux clk16m_rc clkdi3/8 ce_clk2m_rc ce
audio0pll4x ccu_clkdiv2 audio0pll2x
PLL
hosc div750 clk32k_hosc_d clk32k_hosc timer
dft mux ccu_clkdiv2 audio0pll1x
audio1pll_div2
apb0_clk GATE pclk_reg ccu
audio1pll_div5
occ occ in sys
peripll2x ccu_clkdiv2
ccu_clkdiv2 peripll1x hosc GATE dbgsys_clk_t
dbgsys_clk
test_clk
occ occ in ccu peripll_800m ccu_clkdiv2 periplldiv4
load
hosc
peripll2x peripll1x
video0pll4x video0pll2x GATE clkdiv4 dsi_clk
video1pll4x GATE clkdiv5 de_clk de/dpss_de_logic occ
video1pll2x dsi
audio1pll_div2 audio1pll_div2 test_clk dsi
video0pll1x
peripll2x video0pll4x
video0pll4x video1pll1x
video1pll4x GATE clkdiv5 di_clk occ tcon_lcd
di video1pll4x GATE clkdiv4 clkdiv2y tconlcd_clk
audio1pll_div2 test_clk di
peripll2x
g2d audio1pll_div2
peripll2x
video0pll4x GATE clkdiv5 g2d_clk occ video0pll1x
video1pll4x g2d video0pll4x
audio1pll_div2 test_clk g2d
video1pll1x dpss_tv_logic
GATE clkdiv4 clkdiv2y tcontv_clk
video1pll4x
peripll2x
hosc audio1pll_div2
peripll2x GATE clkdiv4 clkdiv2y ce_clk
occ ce video0pll1x
peripll1x test_clk video0pll4x
video1pll1x CVBS OUT
GATE clkdiv4 clkdiv2y tve_clk
vepll
video1pll4x
GATE clkdiv5 ve_clk occ peripll2x
peripll2x ve audio1pll_div2
test_clk ve
hosc
video0pll1x
hosc GATE avs_clk timer GATE clkdiv5 tvd_clk CVBS IN
video1pll1x
peripll1x
hosc csi
peripll1x peripll2x
peripll2x GATE clkdiv4 clkdiv2y smhc0_clk sd0
video0pll2x GATE clkdiv4 csi_clk occ
audio1pll_div2 csi
video1pll2x test_clk csi
hosc
peripll1x hosc
GATE clkdiv4 clkdiv2y smhc1_clk sd1 peripll1x
peripll2x video0pll1x PAD
audio1pll_div2 GATE clkdiv5 csi_master_clk
video1pll1x
hosc audio1pll_div2
peripll1x audio1pll_div5
peripll2x GATE clkdiv4 clkdiv2y smhc2_clk sd2
peripll_800m hosc
audio1pll_div2 GATE tpadc_clk tpadc
audio0pll1x
hosc spi0
peripll1x
peripll2x GATE clkdiv4 clkdiv2y spi0_clk occ audio0pll1x
audio1pll_div2 spi0 audio1pll_div2 GATE clkdiv5 clkdiv2y audiocode1x_dac_clk adda
test_clk spi0
audio1pll_div5 audio1pll_div5
hosc spi1
peripll1x audio0pll1x
peripll2x GATE clkdiv4 clkdiv2y spi1_clk occ
audio1pll_div2 spi1 audio1pll_div2 GATE clkdiv5 clkdiv2y audiocode1x_adc_clk adda
audio1pll_div5 test_clk spi1
audio1pll_div5
hosc
GATE clkdiv4 clkdiv2y irtx_clk irtx hosc
peripll1x GATE clkdiv4 clkdiv2y ledc_clk ledc
peripll1x
audio0pll1x
audio0pll4x
audio1pll_div2 GATE clkdiv5 clkdiv2y owa_tx_clk owa audio0pll1x
audio1pll_div5 audio0pll4x GATE clkdiv5 clkdiv2y i2s1_clk i2s1
audio1pll_div2
peripll1x audio1pll_div5
audio1pll_div2 GATE clkdiv5 clkdiv2y owa_rx_clk occ audio0pll1x
audio1pll_div5 owa audio0pll4x
test_clk owa clkdiv5 i2s2
audio1pll_div2 GATE clkdiv2y i2s2_clk
audio1pll_div5
audio0pll1x audio0pll4x
audio1pll_div2 clkdiv5 dmic peripll1x
GATE clkdiv2y dmic_clk audio1pll_div2 GATE clkdiv5 clkdiv2y i2s2_asrc_clk occ
audio1pll_div5 i2s2
audio1pll_div5 test_clk i2s2
hosc
clk32k risc ddrpll
clk16m_rc audio1pll_div2
peripll_800m GATE clkdiv5xy risc_clk occ peripll2x GATE clkdiv2xy clkdiv2y dram_clk ddr
peripll1x
risc
risc
cpupll test_clk peripll_800m
audio1pll_div2
clk32k test_clk
1
irrx_clk irrx
GATE clkdiv5 clkdiv2y 0
clk_24m
The following figure shows the block diagram of the PLL distribution.
USB0/1、CSI、Timer、GPIO、PWM、GPADC、AUDIO_CODEC
DCXO 24 MHz
PLL_DDR DRAM、MBUS
DE、DI、G2D、CE、VE、SMHC0/1/2、SPI0/1、DSI、
PLL_PERI(2X)
TCON_LCD、TCON_TV、TV Encoder、CSI
PSI、AHB、APB0、APB1、CE、DI、SMHC0/1/2、SPI0/1、
PLL_PERI(1X)
IR_TX、I2S2_ASRC、TV Decoder、OWA_RX、DSI、RISC CPU
PLL_VE VE
PLL_AUDIO0(1X) I2S1/2、OWA_TX、DMIC、AUDIO_CODEC、TPADC
PLL_AUDIO0(4X) I2S1/2、I2S2_ASRC、OWA_TX、DMIC、AUDIO_CODEC
DE、DI、G2D、SMHC0/1/2、SPI0/1、I2S1/2、I2S2_ASRC、
PLL_AUDIO1(DIV2) OWA_TX、OWA_RX、DMIC、AUDIO_CODEC、 RISC CPU、
TCON_LCD、TCON_TV、TV Encoder、CSI_MST
SPI0/1、I2S1/2、I2S2_ASRC、OWA_TX、OWA_RX、DMIC、
PLL_AUDIO1(DIV5)
AUDIO_CODEC、CSI_MST
External 32k
M
RISC CPU、RISC CPU_AXI、PSI、APB0、APB1、IR_TX、SMHC0/1、USB0/1、
RC16M U RTC_32K
X TIMER、GPIO、AUDIO_CODEC
/512
24.576 MHz
180 MHz to 3.0 GHz 22.5792 MHz
PLL_AUDIO0 24.576 MHz Yes No No < 200 ps 500 us
(24MHz*N.x/M1/M0/P) 24.576*4 MHz
22.5792*4 MHz
Integer mode:
PLL_CPUX = 24 MHz*N/P
The parameter N is the frequency-doubling factor of PLL. The next parameter configuration can proceed after
the PLL relock. The parameter P is a digital post-frequency-division factor, which can be dynamically switched
in real-time, without affecting the normal work of PLL.
NOTE
PLL_CPUX supports dynamic frequency adjustment (modifying the value of N). However, for the system
stability, to configure the frequency of the PLL_CPUX from a higher value to a lower one, switch the clock
source of the CPU to another clock whose frequency is not higher than the current one first, and configure
PLL_CPUX to the target low frequency, and then switch the clock source of the CPU back to PLL_CPUX.
Step 1 Before you configure PLL_CPUX, switch the clock source of CPU to PLL_PERI(1X).
Step 3 Write the PLL Lock Enable bit (bit[29]) of PLL_CPU_CTRL_REG to 0 and then to 1.
NOTE
PLL_AUDIO0 = 24 MHz*N/M0/M1/P/4
PLL_AUDIO1 = 24 MHz*N/M
PLL_AUDIO does not support dynamic adjustment because changing any parameter of N, M0, M1, and P will
affect the normal work of PLL, and the PLL will need to be relocked.
Generally, PLL_AUDIO only needs two frequency points: 24.576*4 MHz or 22.5792*4 MHz. For these two
frequencies, there are usually special recommended matching factors. To implement the desired frequency
point of PLL_AUDIO, you need to use the decimal frequency-division function, so follow the steps below:
Step 3 Configure PLL_AUDIOx Pattern0 Control Register to enable the digital spread spectrum.
NOTE
When the P factor of PLL_AUDIO is an odd number, the clock output is an unequal-duty-cycle signal.
Frequency- PLL
Clock Source VCO Post Frequency- Actual Operating
Mode doubling Output Divisor Description
(MHz) (MHz) Division Frequency (MHz)
N (MHz)
4 384
For audio-
5 614.4 25 24.576 related
modules
2 589.824
Provides clock
Decimal 3 393.216 source for
24 98.304 2359.296 2 1179.648
divider 6 196.608 peripheral
devices
12 98.304
Frequency- PLL
Clock Source VCO Post Frequency- Actual Operating
Mode doubling Output Divisor Description
(MHz) (MHz) Division Frequency (MHz)
N (MHz)
For audio-
48 24.576 related
modules
5 471.8592
Step 1 Make sure the PLL is enabled. If not, refer to section 3.3.4.4 Enabling the PLL to enable the PLL.
Step 2 Configure the PLL_OUTPUT_ENABLE bit (bit[27]) of the PLL control register as 0 to disable the output
gate of the PLL because general PLLs are unavailable in the process of frequency modulation.
Step 3 Configure the N and M factors. (It is not suggested to configure M1 factor)
Step 4 Write the LOCK_ENABLE bit (bit[29]) of the PLL control register to 0 and then to 1.
Step 5 Wait for the LOCK bit (bit[28]) of the PLL control register to 1.
Step 2 Write the PLL_ENABLE bit and the LDO_EN bit of the PLL control register to 1, write the
PLL_OUTPUT_GATE bit of the PLL control register to 0.
Step 6 Write the PLL_OUTPUT_GATE bit of the PLL control register to 1 and then the PLL will be available.
Step 1 Write the PLL_ENABLE bit (bit[31]) and the LDO_EN bit of the PLL control register to 0.
Step 2 Write the LOCK_ENABLE bit (bit[29]) of the PLL control register to 0.
CAUTION
In the normal use of PLLs, it is unsuggested to enable and disable the PLLs frequently. Turning on and off the
PLLs will cause mutual interference between PLLs, which will affect the stability of the system. When the
clock is unnecessary, you can write 0 to the PLL_OUTPUT_EN bit of the PLL control register to disable the
output gate of the PLL, instead of writing 0 to the Enable bit to disable the PLL.
The bus clock supports dynamic switching, but the process of switching needs to follow the following two rules.
From a higher frequency to a lower frequency: switch the clock source first, and then set the frequency
division factor;
From a lower frequency to a higher frequency: configure the frequency division factor first, and then
switch the clock source.
For the Bus Gating Reset register of a module, the reset bit is de-asserted first, and then the clock gating bit is
enabled to avoid potential problems caused by the asynchronous release of the reset signal.
For all module clocks except the DDR clock, configure the clock source and frequency division factor first, and
then release the clock gating (that is, set to 1). For the configuration order of the clock source and frequency
division factor, follow the rules below:
With the increasing of the clock source frequency, configure the frequency division factor before the clock
source;
With the decreasing of the clock source frequency, configure the clock source before the frequency
division factor.
The spread spectrum technology is to convert a narrowband signal into a wideband signal. It helps to reduce
the effect of electromagnetic interference (EMI) associated with the fundamental frequency of the signal.
N 1 X
f 24MHz, 0 X 1
P M0 1 M1 1
Where,
When M1 = 0, M0 = 0, and P = 1 (no frequency division), the calculation formula of PLL frequency can be
simplified as follows:
f N 1 X 24MHz, 0 X 1
[ f1 , f2 ] N 1 [ X1 , X2 ] 24MHz
Where, SDM_BOT and WAVE_STEP are bits of the PLL pattern control register, and PREQ is the frequency of
the spread spectrum.
NOTE
Different PLLs have different calculate formulas, refer to the CTRL register of the corresponding PLL in
section 3.3.6 Register Description.
Configuration Procedure
a) Calculate the factor N and decimal value X according to the PLL frequency and PLL frequency
formula. Refer to the control register of the corresponding PLL (named PLL_xxx_CTRL_REG,
where xxx is the module name) in 3.3.6 Register Description for the corresponding PLL frequency
formula.
b) Write M0, M1, N, and PLL frequency to the PLL control register.
Copyright©Allwinner Technology Co.,Ltd. All Rights Reserved. 54
Confidential
c) Configure the SDM_Enable bit (bit[24]) of the PLL control register to 1 to enable the spread
spectrum function.
a) Calculate the SDM_BOT and WAVE_STEP of the pattern control register according to decimal
value X and spread spectrum frequency (the bit[18:17] of the PLL_PAT register)
d) Write SDM_BOT, WAVE_STEP, PREQ, SPR_FREQ_MODE, and SDM_CLK_SEL to the PLL pattern
control register, and configure the SIG_DELT_PAT_EN bit (bit[31]) of this register to 1.
Step 3 Delay 20 us
Configuration Example
The following example shows how to configure the spread spectrum frequency as 605.3 MHz to 609.7 MHz.
[605.3, 609.7]
N 1 [ X1 , X2 ]
24
600 [5.3,9.7]
24
24 1 [5.3 / 24, 9.7/24]
Obviously,
If M0 = 1, M1=0, P = 1, then total frequency division factor is (M0 + 1) *1 = 2, so the actual output frequency of
PLL is 1212.1 MHz to 1219.4 MHz.
Then calculate the values of SDM_BOT and WAVE_STEP according to the formulas, and follow the steps
described in Configuration Procedure.
NOTE
The MBUS clock is from the 4 frequency-division of PLL_DDR, and it has the same source with the DRAM clock.
3.3.6.41 0x063C G2D Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.46 0x070C DMA Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.47 0x073C HSTIMER Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.49 0x078C DBGSYS Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.50 0x07AC PWM Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.51 0x07BC IOMMU Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.53 0x0804 MBUS Master Clock Gating Register (Default Value: 0x0000_0000)
3.3.6.54 0x080C DRAM Bus Gating Reset Register (Default Value: 0x0000_0001)
3.3.6.58 0x084C SMHC Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.59 0x090C UART Bus Gating Reset Register (Default Value: 0x0000_0000)
NOTE
3.3.6.60 0x091C TWI Bus Gating Reset Register (Default Value: 0x0000_0000)
NOTE
3.3.6.63 0x096C SPI Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.65 0x097C EMAC Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.67 0x09CC IRTX Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.68 0x09EC GPADC Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.69 0x09FC THS Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.73 0x0A20 I2S/PCM Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.76 0x0A2C OWA Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.78 0x0A4C DMIC Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.81 0x0A5C AUDIO_CODEC Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.84 0x0A8C USB Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.85 0x0ABC DPSS_TOP Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.87 0x0B4C DSI Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.89 0x0B7C TCONLCD Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.91 0x0B9C TCONTV Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.92 0x0BAC LVDS Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.94 0x0BBC TVE Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.96 0x0BDC TVD Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.101 0x0C1C CSI Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.103 0x0C5C TPADC Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.106 0x0D0C RISC_CFG Bus Gating Reset Register (Default Value: 0x0000_0000)
3.3.6.107 0x0F04 PLL Lock Debug Control Register (Default Value: 0x0000_0000)
0 R/W UDF When only RISC CPU exists, the RISC reset is de-asserted, and the
ARM reset is asserted, so the RISC_SOFT_RSTN bit is 1 by default.
When RISC coexists with ARM, the ARM reset is de-asserted, and
the RISC reset is asserted, so the RISC_SOFT_RSTN bit is 0 by
default. But whether RISC and ARM are locked is controlled by
the eFuse bit of SID module.
3.3.6.112 0x0F30 CCU FANOUT Clock Gate Register (Default Value: 0x0000_0000)
3.4.1 Overview
The system has several ways to boot. It has an integrated on-chip Boot ROM (BROM) that is considered the
primary program-loader. On the startup process, the F133 starts to fetch the first instruction from address 0x0,
where is the BROM located at.
The BROM system is divided into two parts: the firmware exchange launch (FEL) module and the Medium Boot
module. FEL is responsible for writing the external data to the local NVM, and Medium Boot is responsible for
loading an effective and legitimate BOOT0 from NVM and running.
Supports GPIO pin and eFuse to select the boot media type
SD card
eMMC
There are two ways to select the boot medium: GPIO Pin Select and eFuse Select. On startup, the BROM will
read the state of BOOT_MODE, and decide whether the GPIO or eFuse to select the type of boot medium based
on the state of BOOT_MODE. The BOOT_MODE is the bit of the SID module (register: 0x03006210).
If the state of the BOOT_MODE is 0, the boot medium is decided by the value of the GPIO pin. The following
table shows the boot medium priority. The boot medium priority describes the possibility that each medium
to be selected as the boot medium. The BROM reads the boot0 of the medium with the highest priority first. If
the medium does not exist or has any problems, the BROM will try the next medium. Otherwise, the medium
will be selected as the boot medium.
NOTE
The status of the GPIO boot select pin can be read by the bit[12:11] of the system configuration module
(register: 0x03000024).
If the state of the BOOT_MODE is 1, the boot medium is decided by the value of eFuse_Boot_Select_Cfg. The
eFuse_Boot_Select_Cfg is divided into 4 groups and each group is 3-bit. The following table shows the groups
of eFUSE_Boot_Select.
NOTE
The status of the efuse boot select pin can be read by the bit[27:16] of the SID module (register:
0x03006210).
eFuse_Boot_Select_Cfg[11:0] Group
eFuse_Boot_Select_Cfg[2:0] eFuse_Boot_Select_1
eFuse_Boot_Select_Cfg[5:3] eFuse_Boot_Select_2
eFuse_Boot_Select_Cfg[8:6] eFuse_Boot_Select_3
eFuse_Boot_Select_Cfg[11:9] eFuse_Boot_Select_4
For example, eFuse_Boot_Select_2 will not take effect unless eFuse_Boot_Select_1 is set as 0x111,
eFuse_Boot_Select_3 will not take effect unless eFuse_Boot_Select_2 is set as 0x111, and so on.
The following table shows the boot medium priority for the different values of eFuse_Boot_Select_n, where n
= [4:1]. The eFuse_Boot_Select_1 to eFuse_Boot_Select_3 are the same setting. But for eFuse_Boot_Select_4,
if its value is 0x111, the BROM will select the boot medium in the Try mode. The BROM in the Try mode follows
the order below to select the boot medium:
Hotplug Flag
Read Hotplug
Hotplug Process
Flag
others
Selected Unselected
FEL_SEL
Fail
Mandatory Upgrade Try Media Boot
Process Process
Pass
Mandatory Upgrade
Finishes Run Boot0
Hotplug Process
The Hotplug Flag determines whether the system will do Hotplug boot, if the CPU Hotplug Flag value is equal
to 0xFA50392F, then read the Soft Entry Register and the system will jump to the Soft Entry Address. The
following figure shows the CPU0 Hotplug Process.
NOTE
If the FEL pin is detected to pull low, the system will jump to the mandatory upgrade process. The following
figure shows the mandatory upgrade process.
Mandatory Upgrade
Start
End
NOTE
The status of the FEL pin is the bit[8] of the system configuration module (register: 0x03000024).
FEL Process
When the system chooses to enter the Mandatory Upgrade Process, the system will jump to the FEL process.
The following figure shows the FEL upgrade process.
FEL Start
Clock_init
USB_init
Connected
USB enums
Received
Yes Executed No
successfully
If the value of the Fast Boot register (0x07090120) in RTC module is not zero, the system will enter the Fast
Boot Process. The following table shows the boot medium priority for different values of the Fast Boot register.
NOTE
The bit[28:0] of Fast Boot register is used to record the media information.
The try process is SMHC0->SPI NOR->SPI NAND->EMMC2_USER->EMMC2_BOOT.
3.5.1 Overview
The system configuration module is used to configure parameters for system domain, such as SRAM, CPU, PLL,
BROM, and so on.
3.5.3.5 0x0168 240ohms Resistor Manual Control Register (Default Value: 0x0000_0033)
3.6 Timer
3.6.1 Overview
The timer module implements the timing and counting functions. The timer module includes timer0, timer1,
watchdog and audio video synchronization (AVS).
The timer0 and timer1 are completely consistent. The main features for timer0 and timer1 are as follows:
Alternative count clock: LOSC or OSC24M. The LOSC can be either the internal or external low-frequency
clock, and the external one has more accuracy.
Supports two timing modes: periodic mode and single counting mode
The watchdog is used to transmit a reset signal to reset the entire system when an exception occurs in the
system. The main features for the watchdog are as follows:
The AVS is used to synchronize the audio and video. The AVS module includes AVS0 and AVS1, which are
completely consistent. The main features for the AVS are as follows:
The following figure shows the functional block diagram of the timer module.
APB0
reset
Watchdog Timer AVS
irq irq
The watchdog, timer (including timer0 and timer1), and AVS are all mounted at the APB0 bus. The system
configures the parameters of these configure registers via APB0 bus.
The timer and watchdog are both down counters and support generating interrupts after the counting value
reaches 0.
For watchdog, the system is responsible for configuring the interval value. If the system fails to restart the
watchdog regularly because of some exceptional situations, such as the bus hang, the watchdog will send out
a Watchdog Reset External signal to reset the system. And the signal will be transmitted to the Reset pad to
reset the PMIC.
3.6.3.1 Timer
The timer (including timer0 and timer1) is a 32-bit down counter. The counter value is decremented by 1 on
each rising edge of the timer clock.
The following figure shows the block diagram for the timer.
/1
/2
IRQ EN
/4
Single Counting
/8 Timer 0
OSC24M Mode
Yes
/16 Interval Value Enable IV = 0? Pending IRQ
LOSC /32
Timer 1 Periodic Mode
/64
/128
The clock source for the timer can be either OSC24M or LOSC. For LOSC, it can be either the internal or external
low-frequency clock. The external one has more accuracy.
Each timer has a prescale that divides the working clock frequency by 1, 2, 4, 8, 16, 32, 64, or 128. And each
timer can generate independent interrupts.
Timing Modes
The timer has two timing modes: the single counting mode and periodic mode. You can configure the timing
mode via the bit[7] of TMRn_CTRL_REG (n = 0 or 1). The value 0 is for the period mode and value 1 is for the
single counting mode.
In the single counting mode, the timer starts counting from the interval value and generates an interrupt
after the counter decreases to 0, and then stops counting. It starts to count again only when a new interval
value is loaded.
Periodic Mode
In the periodic mode, the timer restarts another round of counting after generating the interrupt. It
reloads data from the TMRn_INTV_VALUE_REG and then continues to count.
TMRn_INTV_VALUE_REG TMRn_CUR_VALUE_REG
Ttimer TMRn_CLK_PRES
TMRn_CLK_SRC
Where,
1. Configure the timer parameters clock source, prescale factor, and timing mode by writing
TMRn_CTRL_REG. There is no sequence requirement of configuring the parameters.
b) Write bit[1] of TMRn_CTRL_REG to load the interval value to the timer. The value of the bit will be
cleared automatically after loading the interval value.
3. Write bit[0] of TMRn_CTRL_REG to start the timer. To get the current value of the timer, read
TMRn_CUR_VALUE_REG.
1. Enable interrupts for the timer: write the enable bit of the corresponding interrupt in TMR_IRQ_EN_REG
for the timer. The timer will generate an interrupt everytime the count value reaches 0.
2. After entering the interrupt process, write the pending bit of the corresponding interrupt in
TMR_IRQ_STA_REG to clear the interrupt pending, and execute the process of waiting for the interrupt.
3.6.3.2 Watchdog
The watchdog is a 32-bit down counter. The counter value is decremented by 1 on each rising edge of the count
clock.
The following figure shows the block diagram for the watchdog.
16k Cycles
32k Cycles Time Yes
Reset Mode Whole System Enable Pending Reset
64k Cycles Out?
No
96k Cycles
32 KHz 128k Cycles Watchdog Restart
160k Cycles
192k Cycles
Time Yes
Others Cycles Interrupt Mode Enable Pending IRQ
out?
No
Restart
The clock source of the watchdog is OSC24M/750. There are 12 configurable initial count values.
Operating Modes
The watchdog has two operating modes: the interrupt mode and reset mode.
In the interrupt mode, when the counter value reaches 0 and WDOG_IRQ_EN_REG is enabled, the
watchdog generates an interrupt.
In the reset mode, when the counter value reaches 0, the watchdog generates a reset signal to reset the
entire system.
You can configure the operating mode for the watchdog via the bit[1:0] of the WDOG_CFG_REG. The value 0x2
is for the interrupt mode and the value 0x1 is for the reset mode.
Both the interrupt mode and reset mode support Watchdog Restart. You can make the watchdog to count
from the initial value at any time by configuring the WDOG_CTRL_REG: write 0xA57 to bit[12:1], then write 1
to bit[0].
1. Write the bit[1:0] of WDOG_CFG_REG to configure the watchdog operating mode so that the watchdog
can generate interrupts or output reset signals.
In the interrupt mode, the watchdog is used as a counter. It generates an interrupt everytime the count value
reaches 0.
2. After entering the interrupt process, write the pending bit of WDOG_IRQ_STA_REG to clear the interrupt
pending and execute the process of waiting for the interrupt.
3.6.3.3 AVS
The AVS is a 33-bit up counter. The counter value is increased by 1 on each rising edge of the count clock. There
is a clock gate in CCU module to control the output of the AVS counter. To operate the AVS, open the clock
gate first.
The following figure shows the block diagram for the AVS.
AVS0
Cycle Output
OSC24M Enable Pause
AVS1
The clock source of the AVS is OSC24M. There is a 12-bit division factor for each AVS, N0 for AVS0 and N1 for
AVS1. When the timer increases from 0 to N1 or N2, the AVS counter adds 1. When the counter reaches 33-bit
upper limit, the AVS will start to count from the initial value again.
The AVS supports changing the initial value and division factor at anytime. And the AVS supports restarting
from the initial value or pausing at anytime.
3. Write AVS_CNT_CTL_REG to enable the AVS. You can pause the AVS at any time.
The following example shows how to make a one-millisecond delay with the clock source selected as OSC24M,
the operating mode sets as single counting mode, and the pre-scale sets as 2.
The following example shows how to make the watchdog to generate a reset signal to the whole system after
1 second. The clock source for the watchdog is OSC24M/750.
The following example shows how to restart the watchdog. In this example, the clock source is OSC24M/750,
the interval value is 1 second, and the watchdog operating mode is the reset mode.
If the execution time of “other codes” is shorter than 1 second, the watchdog will restart from the interval
value before it count to zero and generates the reset signal. Otherwise, the watchdog will reset the whole
system before the code “writel(readl(WDOG_CTRL)|(0xA57<<1)|(1<<0), WDOG_CTRL)” is executed.
----other codes---
NOTE
Take the system clock and timer clock source into consideration when setting the interval value.
NOTE
Take the system clock and timer clock source into consideration when setting the interval value.
3.7.1 Overview
The high speed timer (HSTimer) module consists of HSTimer0 and HSTimer1. HSTimer0 and HSTimer1 are down
counters that implement timing and counting functions. They are completely consistent. Compared with the
timer module, the HSTimer module provides more precise timing and counting.
Single Counting
N_Mode
Mode
IRQ EN
Yes
Interval Value
AHBCLK HSTimer Enable IV=0 ? Pending IRQ
(IV)
The HSTimers are 56-bit down counters. The counter value is decremented by 1 on each rising edge of the
count clock. Each HSTimer has a prescaler that divides the working clock frequency of each working timer by 1,
2, 4, 8, or 16.
AHB0
AHB0_CLK
High Speed Timer irq
The HSTimer module is mounted at AHB0, and can control the registers via AHB0. AHB0 is the clock source of
the HSTimer. When the count value reaches zero, the HSTimer generates an interrupt.
The HSTimer has two count modes: one-shot mode and periodic mode. You can configure the timing mode via
the bit[7] of HS_TMRn_CTRL_REG (n = 0 or 1). The value 0 is for the period mode and value 1 is for the one-
shot mode.
One-shot Mode
When the count value of the HSTimer reaches 0, the HSTimer stops counting. The HSTimer starts to count
again only when a new value is loaded.
Periodic Mode
The HSTimer counts continuously. When the count value of the HSTimer reaches 0, the HSTimer reloads
an initial value from HS_TMRn_INTV_LO_REG and HS_TMRn_INTV_HI_REG and then continues to count.
The HSTimer has two operating modes: the normal mode and test mode. You can configure the operating
mode via the bit[31] of HS_TMRn_CTRL_REG. The value 0 is for the normal mode and value 1 is for the test
mode.
Normal Mode
In the normal mode, the HSTimer is used as a 56-bit down counter, which can finish one-shot counting
and periodic counting. The interval value for the HSTimer consists of two parts: HS_TMRn_INTV_LO_REG
forms the bit[31:0] and HS_TMRn_INTV_HI_REG forms the bit[55:32]. To read or write the interval value,
HS_TMRn_INTV_LO_REG should be done before HS_TMRn_INTV_HI_REG.
Test Mode
In the test mode, the HSTimer is used as a 24-bit down counter. HS_TMRn_INTV_LO_REG must be set to
0x1, and HS_TMRn_INTV_HI_REG acts as the initial value for the HSTimer.
The following formula describes the relationship among HSTimer parameters in the normal mode.
Where,
Enable HSTimer
1. AHB0 clock management: Open the clock gate of AHB0 and de-assert the soft reset of AHB0 in CCU.
2. Configure the corresponding parameters of the HSTimer: clock source, prescaler factor, operating mode,
and timing mode. There is no sequence requirement when writing the above parameters to
HS_TMRn_CTRL_REG.
3. Write the initial value: Write the lower 32 bits of the initial value to HS_TMRn_INTV_LO_REG first, and
then the higher 24 bits to HS_TMRn_INTV_HI_REG. Normally, write the bit[1] of HS_TMRn_CTRL_REG to
load the initial value. If the HSTimer is in the timing stop stage, write 1 to the bit[1] and bit[0] of
HS_TMRn_CTRL_REG at the same time to reload the initial value.
1. Enable interrupt: Write the corresponding interrupt enable bit of HS_TMR_IRQ_EN_REG, when the
counting time of HSTimer reaches, the corresponding interrupt generates.
2. After entering the interrupt process, write HS_TMR_IRQ_STAS_REG to clear the interrupt pending.
The following example shows how to make a 1 us delay with HSTimer0. The frequency of the AHB0 clock is 100
MHz, the operating mode is the normal mode, the timing mode is single counting mode, and the pre-scale is 2.
writel(0x90, HS_TMR0_CTRL);
//Set the operating mode as Normal Mode, the pre-scale as 2, and the timing mode as Single Counting Mode.
0 R/W 0x0 By setting the bit to 0 before the timer counts to 0, the timer will be
paused. The bit will be locked to 0 for at least 2 cycles. Within the 2
cycles, you cannot set the bit to 1 to restart the timer.
The timer supports updating the interval value in the pause state. To
start from the updated interval value, set both the reload bit and
enable bit to 1.
Additionally, in the one-shot mode, after the count value reaches 0,
the system will automatically change the bit to 0 to stop the timer.
NOTE
HSTimer0 is a 56-bit counter. The interval value consists of two parts: HS_TMR0_INTV_VALUE_LO acts as
the bit[31:0] and HS_TMR0_INTV_VALUE_HI acts as the bit[55:32]. To read or write the interval value,
HS_TMR0_INTV_LO_REG should be done before HS_TMR0_INTV_HI_REG.
NOTE
HSTimer0 is a 56-bit counter. The current value consists of two parts: HS_TMR0_CUR_VALUE_LO acts as the
bit[31:0] and HS_TMR0_CUR_VALUE_HI acts as the bit[55:32]. To read or write the current value,
HS_TMR0_CUR_VALUE_LO should be done before HS_TMR0_CUR_VALUE_HI.
0 R/W 0x0 By setting the bit to 0 before the timer counts to 0, the timer will be
paused. The bit will be locked to 0 for at least 2 cycles. Within the 2
cycles, you cannot set the bit to 1 to restart the timer.
The timer supports updating the interval value in the pause state.
To start from the updated interval value, set both the reload bit and
enable bit to 1.
Additionally, in the one-shot mode, after the count value reaches 0,
the system will automatically change the bit to 0 to stop the timer.
NOTE
HSTimer1 is a 56-bit counter. The interval value consists of two parts: HS_TMR1_INTV_VALUE_LO acts as
the bit[31:0] and HS_TMR1_INTV_VALUE_HI acts as the bit[55:32]. To read or write the interval value,
HS_TMR1_INTV_LO_REG should be done before HS_TMR1_INTV_HI_REG.
NOTE
HSTimer1 is a 56-bit counter. The current value consists of two parts: HS_TMR1_CUR_VALUE_LO acts as the
bit[31:0] and HS_TMR1_CUR_VALUE_HI acts as the bit[55:32]. To read or write the current value,
HS_TMR1_CUR_VALUE_LO should be done before HS_TMR1_CUR_VALUE_HI.
3.8.1 Overview
The PLIC is only used for sampling, priority arbitration and distribution for external interrupt sources.
The interrupt can be configured as machine mode and super user mode
Up to 256 interrupt source sampling, supporting level interrupt and pulse interrupt
Maintains independently the interrupt enable for each interrupt mode (machine/super user)
Maintains independently the interrupt threshold for each interrupt mode (machine/super user)
Offset: 0x0000+n*0x0004
Register Name: PLIC_PRIO_REGn
(0<n<256)
Bit Read/Write Default/Hex Description
31:1 / / /
PLIC_PRIO
PLIC Priority
Support for 32 different levels of priority.
Where, a priority sets to 0 indicates that the interrupt is invalid.
0 R/W 0x0 Machine mode interrupts have unconditionally higher priority
than super-user mode interrupts. When the interrupt target mode
is the same, priority 1 is the lowest priority, priority 31 is the
highest priority. When multiple interrupts of the same priority are
waiting arbitration, the interrupt source ID is compared. The
smaller ID has the higher priority.
3.8.4.2 0x1000+n*0x0004 (0≤n<9) PLIC Interrupt Pending Register n (Default Value: 0x0000_0000)
3.8.4.3 0x2000+n*0x0004 (0≤n<9) PLIC Machine Mode Interrupt Enable Register n (Default Value: 0x0000_0000)
3.8.4.4 0x2080+n*0x0004 PLIC Superuser Mode Interrupt Enable Register n (0≤n<9) (Default Value: 0x0000_0000)
3.9.1 Overview
The direct memory access (DMA) is a method of transferring data between peripherals and memories
(including the SRAM and DRAM) without using the CPU. It is an efficient way to offload data transfer duties
from the CPU. Without DMA, the CPU has to control all the data transfers. While with DMA, the DMAC directly
transfers data between a peripheral and a memory, between peripherals, or between memories.
Up to 16 DMA channels
Provides 32 peripheral DMA requests for data reading and 32 peripheral DMA requests for data writing
Memory Bus
DMA_CHANNEL0 DMA_MPORT
DMA_CHANNEL1
DMA_FIFO CTRL
DRQs
DMA_ARBITER
DMA_CHANNEL 14
DMA_CHANNEL 15
Sub-block Description
Arbitrates the DMA read/write requests from all channels, and converts
DMA_ARBITER
the requests to the read/write requests of ports.
DMA transfer engine. Each channel is independent. When the DMA
requests from multiple peripherals are valid simultaneously, the channel
with the highest priority starts data transfer first. The system uses the
polling mechanism to decide the priorities of DMA channels. When
DMA_CHANNELs
DMA_ARBITER is idle, channel 0 has the highest priority, whereas channel
15 has the lowest priority. When DMA_ARBITER is busy processing the
request from channel n, channel (n+1) has the highest priority. For n = 15,
the channel (n + 1) should be channel 0.
DMA requests. Peripherals use the DMA request signals to request a data
DRQs
transfer.
Receives the read/write requests from DMA_ARBITER, and converts the
DMA_MPORT requests to the corresponding MBUS access requests. It is mainly used for
accessing the DRAM.
The port for accessing the AHB Master. It is mainly used for accessing the
DMA_HPORT
SRAM and IO devices.
DMA_FIFO CTRL Internal FIFO cell control module.
DMA_REG is the common register module that is mainly used to resolve
DMA_REG Interface
AHB demands.
DMA_CLKGATE The control module for hardware auto clock gating.
The DMAC integrates 16 independent DMA channels and each channel has an independent FIFO controller.
When the DMA channel starts, the DMAC gets a DMA descriptor from the DMA_DESC_ADDR_REG and uses it
as the configuration information for the data transfer of the current DMA package. Then the DMAC can transfer
data between the specified devices. After transferring a DMA package, the DMAC judges if the current channel
transfer is finished via the linked address in the descriptor. If the linked address shows all the packages are
transferred, the DMAC will end the chain transmission and close the channel.
3.9.3.1 Clock
The DMAC is on MBUS. The clock of MBUS influences the transfer efficiency of the DMAC.
Device 0
Device 1
Device 2
Device 3
BUS
AHB Slave Interface DMA
Interface
Device 4
Device 5
Device 14
Device 15
The following table shows the source DRQ types and destination DRQ types of different ports.
The DMAC descriptor is the configuration information of DMA transfer that decides the DMA working mode.
Each descriptor includes 6 words: Configuration, Source Address, Destination Address, Byte Counter,
Parameter, and Link. The following figure shows the structure of the DMA descriptor.
Configuration
Source
Address
Destination
Address
Byte Counter
Parameter
Link
- Address counting mode: For both the source and destination devices, there are two address counting
modes: the IO mode and linear mode. The IO mode is for IO devices whose address is fixed during
the data transfer and the linear mode is for the memory whose address is increasing during the data
transfer.
- Transferred block length: The amount of data that non-memory peripherals can transfer in a valid
DRQ. The block length supports 1 bit, 4 bits, 8 bits, and 16 bits.
- Transferred data width: The data width of operating the non-memory peripherals. The data width
supports 8 bits, 16 bits, 32 bits, and 64 bits.
NOTE
The configuration supports BMODE mode. The BMODE is used in the following scenario: the source is
an IO device, and the destination is a memory device. Setting the BMODE mode can limit the amount
of block data transferred in DMA block transmission to the amount of data transferred when the DRQ
threshold of the source IO device is 1. For example,
DMA reads data from the source address and then writes data to the destination address.
Both the DMA source and destination addresses have 34 bits. In the descriptor, because there are only 32
bits in the Source/Destination Address field, another 2 bits are stored in the Parameter field.
The following table shows the details of the related fields in the descriptor.
Real DMA source address (in byte mode) = {Parameter [17:16], Source Address [31:0]};
Real DMA destination address (in byte mode) = {Parameter [19:18], Destination Address [31:0]};
Byte counter: Configure the data amount of a package. The maximum value is (2^25-1) bytes. If the data
amount of the package reaches the maximum value, even if DRQ is valid, the DMA will stop the current
transfer.
Parameter: Configure the interval between the data block. The parameter is valid for non-memory
peripherals. When DMA detects that the DRQ is high, the DMA transfers the data block and ignores the
status changes of the DRQ until the data transfer finishes. After that, the DMA waits for certain clock
cycles (WAIT_CYC) and executes the next DRQ detection.
Link: If the value of the link is 0xFFFFF800, the current package is at the end of the linked list. The DMAC
will stop the data transfer after transferring the package; otherwise, the value of the link is considered
as the descriptor address of the next package.
3.9.3.5 Interrupts
There are three kinds of DMA interrupts: the half package interrupt, package end interrupt, and queue end
interrupt.
Half package interrupt: When enabled, the DMAC sends out a half package interrupt after transferring half of
a package.
Package end interrupt: When enabled, the DMAC sends out a package end interrupt after transferring a
complete package.
Queue end interrupt: When enabled, the DMAC sends out a queue end interrupt after transferring a complete
queue.
Notice that when CPU does not respond to the interrupts timely, or two DMA interrupts are generated very
closely, the later interrupt may override the former one. That is, from the perspective of the CPU, the DMAC
has only a system interrupt source.
NOTE
The DMAC has 16 channels and 2 groups of interrupts. The channel [7:0] corresponds to one group of interrupt,
the channel [15:8] corresponds to anther group of interrupt.
The DMA_CLK_GATE module is a hardware module for controlling the clock gating automatically. It provides
clock sources for sub-modules in DMAC and the module local circuits.
The DMA_CLK_GATE module consists of two parts: the channel clock gate and the common clock gate.
Channel clock gate: Controls the DMA clock of the DMA channels. When the system accesses the register of
the current DMA channel and the DMA channel is enabled, the channel clock gate automatically opens the
DMA clock. With a 16-HCLK-cycle delay after the system finishes accessing the register or the DMA data transfer
is completed, the channel clock gate automatically closes the DMA clock. Also, the clock for the related circuits,
such as for the channel control and FIFO control modules, will be closed.
Common clock gate: Controls the clocks of the DMA common circuits. The common circuits include the
common circuit of the FIFO control module, MPORT module, and MBUS. When all the DMA channels are
enabled, the common clock gate automatically closes the clocks for the above circuits.
The DMA clock gating can support all the functions stated above or not by software.
The peripherals initiate data transfer by transmitting DMA request signals to the DMAC. After receiving the
request signal, the DMAC converts it to the internal DRQ signal and controls the DMA data transfer.
The DMAC supports two data transfer modes: the waiting mode and handshake mode.
When the DMAC detects a valid external request signal, the DMAC starts to operate the peripheral device.
The internal DRQ always holds high before the transferred data amount reaches the transferred block
length.
When the transferred data amount reaches the transferred block length, the internal DRQ pulls low
automatically.
The internal DRQ holds low for certain clock cycles (WAIT_CYC), and then the DMAC restarts to detect the
external requests. If the external request signal is valid, then the next transfer starts.
When the DMAC detects a valid external request signal, the DMAC starts to operate the peripheral device.
The internal DRQ always holds high before the transferred data amount reaches the transferred block
length.
When the transferred data amount reaches the transferred block length, the internal DRQ will be pulled
down automatically. For the last data transfer of the block, the DMAC sends a DMA Last signal with the
DMA commands to the peripheral device. The DMA Last signal will be packed as part of the DMA
commands and transmitted on the bus. It is used to inform the peripheral device that it is the end of the
data transfer for the current DRQ.
When the peripheral device receives the DMA Last signal, it can judge that the data transfer for the current
DRQ is finished. To continue the data transfer, it sends a DMA Active signal to the DMAC.
NOTE
One DMA Active signal will be converted to one DRQ signal in the DMA module. To generate multiple
DRQs, the peripheral device needs to send out multiple DMA Active signals via the bus protocol.
When the DMAC received the DMA Active signal, it sends back a DMA ACK signal to the peripheral device.
When the peripheral device receives the DMA ACK signal, it waits for all the operations on the local device
completed, and both the FIFO and DRQ status refreshed. Then it invalidates the DMA Active signal.
When the DMAC detects the falling edge of the DMA Active signal, it invalidates the corresponding DMA
ACK signal, and restarts to detect the external request signals. If a valid request signal is detected, the next
data transfer starts.
DMAC DEVICE
For the non-IO devices whose start address is not 32-byte-aligned, the DMAC will adjust the address to 32-
byte-aligned through the burst transfer within 32 bytes. Adjusting address to 32-byte-aligned improves the
DRAM access efficiency.
The following example shows how the DMAC adjusts the address: when the peripheral device of a DMA channel
is a non-IO device whose start address is 0x86 (not 32-byte-aligned), the DMAC firstly uses a 26-byte burst
transfer to align the address to 0xA0 (32-byte-aligned), and then transfers data by 64-byte burst (the maximum
transfer amount that MBUS allows).
The IO devices do not support address alignment, so the bit width of IO devices must match the address offset;
otherwise, the DMAC will ignore the inconsistency and directly transmit data of the corresponding bit width to
the address.
The address of the DMA descriptor does not support the address auto-alignment. Make sure the address is
word-aligned; otherwise the DMAC cannot identify the descriptor.
The DMAC clock is synchronous with the AHB0 clock. Make sure that the DMAC gating bit of AHB0 clock
is enabled before accessing the DMAC register.
The reset input signal of the DMAC is asynchronous with AHB0 and is low valid by default. Make sure that
the reset signal of the DMAC is de-asserted before accessing the DMA register.
To avoid the indefinite state within registers, de-assert the reset signal first, and then open the gating bit
of AHB0.
The DMAC supports Clock Auto Gating function to reduce power consumption, the system will
automatically disable the DMAC clock in the DMAC idle state. Clock Auto Gating is enabled by default.
Step 1 Request DMA channel, and check if the DMA channel is idle by checking if it is enabled. A disabled
channel indicates it is idle, while an enabled channel indicates it is busy.
Step 2 Write the descriptor with 6 words into the memory. The descriptor must be word-aligned. For more
details, refer to section 3.9.3.4 “DMA Descriptor”.
Step 4 Enable the DMA channel, and write the corresponding channel to DMAC_EN_REGN.
Step 6 Start to transmit a package. When half of the package is completed, the DMA sends a Half Package
Transfer Interrupt; when a total package is completed, the DMA sends a Package End Transfer
Interrupt. These interrupt status can be read by DMAC_IRQ_PEND_REG0.
Step 8 After completing a total package transfer, the DMA decides to start the next package transfer or end
the transfer by the link of the descriptor. If the link is 0xFFFFF800, the transfer ends; otherwise, the
next package starts to transmit. When the transfer ends, the DMA sends a Queue End Transfer
Interrupt.
No
Any Idle?
Yes
Half-Pending Yes
DMA transmit package data
Pkg-Pending
Resume?
Yes
Pause?
No
No
Link = 0xFFFFF800?
Yes
End-Pending
Step 1 Enable interrupt: write the corresponding interrupt enable bit of DMAC_IRQ_EN_REG0. The system
generates an interrupt when the corresponding condition is satisfied.
Step 2 After entering the interrupt process, write to clear the interrupt pending and execute the process of
waiting for the interrupt.
Step 3 Resume the interrupt and continue to execute the interrupted process.
Make sure the transfer bit width of IO devices is consistent with the offset of the start address.
The MBUS protocol does not support the read operation of non-integer words. For the devices whose bit
width is not word-aligned, after receiving the read command, they should resolve the read command
according to their FIFO bit width instead of the command bit width, and ignore the redundant data caused
by the inconsistency of the bit width.
When the DMA transfer is paused, this is equivalent to invalid DRQ. Because there is a certain time delay
between DMA transfer commands, the DMAC will not stop data transfer until the DMAC finishes
processing the current command and the commands in Arbiter (at most 32 bytes data).
writel(0x00001000, mem_address + 0x04); // Set the start address for the source device.
writel(0x20000000, mem_address + 0x08); //Set the start address for the destination device.
writel(0xFFFFF800, mem_address + 0x14); //Set the start address for the next descriptor.
writel(mem_address, 0x01C02000+ 0x100 + 0x08); //Set the start address for the DMA channel0 descriptor.
do{
break;
The DMAC supports increasing data package in transfer, pay attention to the following points:
The 0xFFFFF800 value of DMAC_FDESC_ADDR_REGN indicates that the DMA channel has got back the
descriptor of the last package. The DMA channel will automatically stop the data transfer after transferring
the current package.
To add a package during the data transfer, check if the DMA channel has got back the descriptor of the
last package. If yes, you cannot add any package in the current queue. Request another DMA channel with
a new DRQ to transfer the package. Otherwise, you can add the package by modifying the
DMAC_FDESC_ADDR_REGN of the last package from 0xFFFFF800 to the start address of the to-be-added
package.
To ensure that the modification is valid, read the value of DMAC_FDESC_ADDR_REGN after the
modification. The value 0xFFFFF800 indicates the modification fails and the other values indicate you have
successfully added packages to the queue.
Another problem is, the system needs some time to process the modification, during which the DMA
channel may get back the descriptor of the last package. You can read DMAC_CUR_SRC_REGN and
DMAC_CUR_DEST_REGN and check if the increasing memory address accords with the information of the
added package. If yes, the package is added successfully; otherwise, the modification failed.
To ensure a higher rate of success, it is suggested that you add the package before the half package
interrupt of the penultimate package.
3.9.6.3 0x0010 DMAC IRQ Pending Status Register 0 (Default Value: 0x0000_0000)
3.9.6.4 0x0014 DMAC IRQ Pending Status Register 1 (Default Value: 0x0000_0000)
NOTE
When initializing the DMA Controller, the bit[2] should be set up.
3.9.6.7 0x0100 + N*0x0040 DMAC Channel Enable Register N (Default Value: 0x0000_0000)
3.9.6.8 0x0104 + N*0x0040 DMAC Channel Pause Register N (Default Value: 0x0000_0000)
3.9.6.9 0x0108 + N*0x0040 DMAC Channel Descriptor Address Register N (Default Value: 0x0000_0000)
3.9.6.10 0x010C + N*0x0040 DMAC Channel Configuration Register N (Default Value: 0x0000_0000)
3.9.6.11 0x0110 + N*0x0040 DMAC Channel Current Source Address Register N (Default Value: 0x0000_0000)
3.9.6.12 0x0114 + N*0x0040 DMAC Channel Current Destination Address Register N (Default Value: 0x0000_0000)
3.9.6.13 0x0118 + N*0x0040 DMAC Channel Byte Counter Left Register N (Default Value: 0x0000_0000)
3.9.6.14 0x011C + N*0x0040 DMAC Channel Parameter Register N (Default Value: 0x0000_0000)
3.9.6.16 0x012C + N*0x0040 DMAC Former Descriptor Address Register N (Default Value: 0x0000_0000)
3.9.6.17 0x0130 + N*0x0040 DMAC Package Number Register N (Default Value: 0x0000_0000)
3.10.1 Overview
The thermal sensors are common elements in wide range of modern system on chips (SoCs) platform. The
thermal sensors are used to constantly monitor the temperature on the chip.
The thermal sensor controller (THS) embeds one thermal sensor located in the CPU. When the temperature
reaches a certain thermal threshold, the thermal sensor can generate interrupts to the software to lower the
temperature via the dynamic voltage and frequency scaling (DVFS) technology.
Temperature accuracy: ±3°C from 0°C to +100°C, ±5°C from -25°C to +125°C
CLK_IN
Clock Div
24 MHz
THS0 Digital
M APB
THS U ADC Logic Reg
THS2 X Process BUS
GN
D Vref
The THS gets one clock source: OSC24M. For details about clock configurations, refer to section 3.3 “CCU”.
The following figure shows the timing requirements for the THS.
TACQ CONV_TIME
ADC_Sample_Frequency
THERMAL_PER
CLK_IN = 24 MHz
3.10.3.3 Interrupts
The THS has four interrupt sources: DATA_IRQ, SHUTDOWN_IRQ, ALARM_IRQ, and ALARM_OFF_IRQ. The
following figure shows thermal sensor interrupt sources.
DATA_IRQ_EN
DATA_IRQ
SHUTDOWN_IRQ_EN THS_IRQ
SHUTDOWN_IRQ
ALARM_IRQ_EN
ALARM_IRQ
ALARM_OFF_IRQ
SHUTDOWN_IRQ: The interrupt is generated when the temperature is higher than the shutdown threshold.
ALARM_IRQ: The interrupt is generated when the temperature is higher than the Alarm_Threshold.
ALARM_OFF_IRQ: The interrupt is generated when the temperature drops to lower than the
Alarm_Off_Thershold. It is triggered at the fall edge.
T = (sensor_data - 2800)/(-14.85)
Start
Enable THS
In the final test (FT) stage, the THS is calibrated through the ambient temperature, and the calibration value is
written in the SID module. The following table shows the THS information in the SID.
Before enabling THS, read eFuse value and write the value to THS_CDATA.
Query Mode
Step 2 Write 0x1 to the bit[0] of THS_BGR_REG to open the THS clock.
Step 3 Write 0x2F to the bit[15:0] of THS_CTRL to set the ADC acquire time.
Step 4 Write 0x1DF to the bit[31:16] of THS_CTRL to set the ADC sample frequency divider.
Step 5 Write 0x3A to the bit[31:12] of THS_PER to set the THS work period.
Step 6 Write 0x1 to the bit[2] of THS_FILTER to enable the temperature convert filter.
Step 7 Write 0x1 to the bit[1:0] of THS_FILTER to select the filter type.
Step 8 Read THS eFuse value from SID, then write the eFuse value to THS_CDATA to calibrate THS.
Step 11 Read the bit[11:0] of THS_DATA, and calculate the THS temperature based on section 3.10.3.4 “THS
Temperature Conversion Formula”.
Interrupt Mode
Step 2 Write 0x1 to the bit0 of THS_BGR_REG to open the THS clock.
Step 3 Write 0x2F to the bit[15:0] of THS_CTRL to set the ADC acquire time.
Step 4 Write 0x1DF to the bit[31:16] of THS_CTRL to set the ADC sample frequency divider.
Step 5 Write 0x3A to the bit[31:12] of THS_PER to set the THS work period.
Step 6 Write 0x1 to the bit2 of THS_FILTER to enable the temperature convert filter.
Step 7 Write 0x1 to the bit[1:0] of THS_FILTER to select the filter type.
Step 8 Read THS eFuse value from SID, and then write the eFuse value to THS_CDATA to calibrate THS.
Step 9 Write 0x1 to the bit[0] of THS_DATA_INTC to enable the interrupt of THS.
Step 11 Put the interrupt handler address into the interrupt vector table.
Step 14 Read the bit[11:0] of THS_DATA, and calculate the THS temperature based on section 3.10.3.4 “THS
Temperature Conversion Formula”.
3.10.6.4 0x0010 THS Data Interrupt Control Register (Default Value: 0x0000_0000)
3.10.6.5 0x0014 THS Shut Interrupt Control Register (Default Value: 0x0000_0000)
3.10.6.6 0x0018 THS Alarm Interrupt Control Register (Default Value: 0x0000_0000)
3.10.6.7 0x0020 THS Data Interrupt Status Register (Default Value: 0x0000_0000)
3.10.6.8 0x0024 THS Shut Interrupt Status Register (Default Value: 0x0000_0000)
3.10.6.9 0x0028 THS Alarm Off Interrupt Status Register (Default Value: 0x0000_0000)
3.10.6.10 0x002C THS Alarm Interrupt Status Register (Default Value: 0x0000_0000)
3.10.6.12 0x0040 THS Alarm Threshold Control Register (Default Value: 0x05A0_0684)
3.10.6.13 0x0080 THS Shutdown Threshold Control Register (Default Value: 0x0000_04E9)
3.11 IOMMU
3.11.1 Overview
The I/O Memory management unit (IOMMU) is designed for the specific memory requirements of products. It
maps the virtual address (sent by peripheral access memory) to the physical address. The IOMMU allows
multiple ways to manage the location of physical address, and it can use physical address which has potentially
conflict mapping for different processes to allocate memory space, and also allow application of non-
continuous address mapping to continuous virtual address space.
Features:
Supports 2 levels TLB (level1 TLB for special using, and level2 TLB for sharing)
Micro TLB: level1 TLB, 64 words. Each peripheral corresponds to a TLB, which caching the level2 page table for
the peripheral.
Macro TLB: level2 TLB, 4K words. Each peripheral shares a level2 TLB for caching the level2 page table.
Prefetch Logic: Each Micro TLB corresponds to a Prefetch Logic. By monitoring each master device to predict
the bus access, the secondary page table corresponding to the address to be accessed can be read from
memory and stored in the secondary TLB to improve hit ratio.
PTW Logic: Page Table Walk, mainly contains PTW Cache and PTW. The PTW Cache is used to store the level1
page table; when the virtual address VA missed in the level1 and level2 TLB, it will trigger the PTW. PTW Cache
can store 512 level1 page tables, that is, 512 words.
PMU: Performance Monitoring Unit, which is used to count hit efficiency and latency.
APB Interface: IOMMU register instantiation module. CPU reads and writes the IOMMU register by APB bus.
IOMMU
VE MBUS64 VA->PA Translation
DI VA->PA Translation
APB
CPU Interface
Prefetch
Logic4
Prefetch
Logic3
Prefetch
Logic2
Prefetch
Logic1
Prefetch
Logic0
PTW Logic
PTW Cache Page Table Walk
3.11.3.1 Initialization
Set IOMMU_INT_ENABLE_REG;
In the process of address mapping, The peripheral virtual address VA[31:12] are retrieved in the Level1 TLB,
when TLB hits, the mapping finished, or they are retrieved in the Level2 TLB in the same way. If TLB hits, it will
write the hit mapping to the Level1 TLB, and hits in Level1 TLB. If Level1 and Level2 TLB are retrieved fail, it will
trigger the PTW. After opening peripheral bypass function by setting IOMMU Bypass Register, IOMMU will not
map the address for peripheral typed the address, and it will output the virtual address as physical address.
The typical scenarios are as follows.
Step 1 The master device sends a transfer command to send the address to the corresponding Micro TLB,
and searches the Level2 page table corresponding to virtual address;
Step 2 If Micro TLB hits, it will return a corresponding physical addresses and the Level2 page table of
permission Index;
Step 3 Address transform module converts the virtual address into physical address, and checks the
permissions at the same time. If pass, the transfer is completed.
Step 1 The master device sends a transfer command to send the address to the corresponding Micro TLB,
and searches the Level2 page table corresponding to virtual address;
Step 3 If Macro TLB hits, it will return the Level2 page table to Micro TLB;
Step 4 Micro TLB receives the page table and puts it to Micro TLB (if this Micro TLB is full, there will happen
the replace activity), at the same time, the page table entry is sent to address translation module;
Step 5 Address transform module converts the virtual address into physical address, and checks the
permissions at the same time. If pass, the transfer is completed.
Step 1 The master device sends a transfer command to send the address to the corresponding Micro TLB,
and searches the Level2 page table corresponding to virtual address;
Step 3 If Macro TLB misses, then it will send the request to the PTW to return the corresponding page table;
Step 4 PTW first accesses PTW Cache, confirms that the required Level1 page table exists in the PTW Cache,
sends the page table to PTW logic;
Step 5 PTW logic returns the corresponding Level2 page table from memory page table according to Level1
page table, checks the effectiveness, and sends to Macro TLB;
Step 6 Macro TLB stores the Level2 page table (there may happen the replace activity), and will return the
Level2 page table to Micro TLB;
Step 7 Micro TLB receives the page table entries and puts it to the Micro TLB (if this Micro TLB is full, there
will happen the replace activity), and sends page table entries to address translation module;
Step 8 Address transform module converts the virtual address into physical address, and checks the
permissions at the same time. If pass, the transfer is completed.
Step 1 The master device sends a transfer command to send the address to the corresponding Micro TLB,
and searches the Level2 page table corresponding to virtual address;
Step 3 If Macro TLB misses, there will send the request to the PTW to return the corresponding page table;
Step 4 PTW accesses PTW Cache, the Level1 page table is unnecessary;
Step 5 PTW accesses memory to get the corresponding Level1 page table and stores it to the PTW Cache
(there may happen the replace activity);
Step 6 PTW logic returns the corresponding Level2 page table from memory page table according to Level1
page table, checks the effectiveness, and sends to Macro TLB;
Step 7 Macro TLB stores the Level2 page table (there may happen the replace activity), and returns the Level
2 page table to Micro TLB;
Step 8 Micro TLB receives the page table entries and puts it to the Micro TLB (if this Micro TLB is full, there
will happen the replace activity), and sends page table entries to address translation module;
Step 9 Address transform module converts the virtual address into physical address, and checks the
permissions at the same time. If pass, the transfer is completed.
Permission error
Step 2 Once the permission checking makes mistake, the new access of the master suspends, but continues
before this access;
Step 1 Invalid Level1 page table is checked when PTW logic reads the new level page table from memory;
Step 2 The PTW reads sequentially two page table entries from the memory (64-bit data, a complete cache
line), and stores in the PTW cache;
Step 3 If the current page table is detected invalid, then the error flag is set, and the interrupt is triggered,
the cache line need to be invalidated.
NOTE
Invalid page table has two situations: the reading target page table from the memory is invalid; and the
page table stored in PTW Cache with target page table is found to be invalid after using;
If a page table is invalid, then the total cache line (that is two page tables) need to be invalidated.
Step 1 Invalid Level2 page table checks when Macro TLB reads the new level page table from memory;
Step 2 The Macro TLB reads sequentially two page table entries from the memory (64-bit data, a complete
cache line), and stores in the Macro TLB;
Step 3 If the current page table is detected invalid, then the error flag is set, and the interrupt is triggered,
the cache line need to be invalidated.
NOTE
Invalid page table has two situations: the reading target page table from the memory is invalid; and the
page table stored in Macro TLB with target page table is found to be invalid after using.
If a page table is invalid, then the total cache line (that is two page tables) need to be invalidated.
Start
Yes
Micro TLB hit
No
Trigger PTW
Yes
No
No
Valid L2 page table
Yes
End
IOMMU page table is defined as Level2 mapping, the first level is 1M address space mapping, the second level
is 4K address space. This version does not support 1K, 16K and other page table size. IOMMU supports a page
table only, its meaning is:
All peripherals connected to IOMMU use the same virtual address space;
Different virtual addresses can map to the same physical address space;
Base address of the page table is defined by software, and it needs 16 KB address alignment; Page table of the
Level2 table item needs 1 KB address alignment. The following figure shows a complete VA-PA address
translation process.
31 14 0
IOMMU_TTB_REG Start address of Level1 page table
31 2019 1211 0
Virtual address(VA) Index of Level1 page table Index of Level2 page tableOffset within page
31 1413 2 1 0
Address of Level1
Start address of Level1 page table Index of Level1 page table 00
page table
31 10 2 1 0
Level1 page table
Start address of Level2 page table Reserved 01
entry
31 10 9 2 1 0
Address of Level2
Start address of Level2 page table Index of Level2 page table 00
page table
31 12 7 4 1 0
Level2 page table
Physical base address ACI 1
entry
31 1211 0
Physical address(PA) Physical base address Offset within page
When the content of multi page tables refreshes or the address of page table changes, all VA-PA mapping which
has been cached in TLB will no longer be valid, then you need configure IOMMU TLB Flush Enable Register to
clear the TLB or PTW Cache. First suspend the access to TLB or Cache, then configure the corresponding Flush
bit of IOMMU TLB Flush Enable Register, after the operation takes effect, the related peripherals can continue
to send new access memory operations.
When some page table is invalid or incorrect mapping, you can set the TLB Invalidation relevant register to
invalidate some TLB VA-PA mapping pairs. There are two modes to invalidate the TLB operation.
Step 1 Set IOMMU TLB Invalidation Mode Select Register to 0 to select mode0;
Step 3 Set configuration values to IOMMU TLB Invalidation Address Mask Register, the requirements are
as follows:
The value of IOMMU TLB Invalidation Address Mask Register cannot be less than the IOMMU TLB
Invalidation Address Register.
The higher bit of IOMMU TLB Invalidation Address Mask Register must be continuous 1, the lower
bit must be continuous 0. For example, 0xfffff000, 0xffffe000, 0xffffc000, 0xffff8000, 0xffff0000
belongs to the legal value; and 0xffffd000, 0xffffb000, 0xffffa000, 0xffff9000, 0xffff7000 belongs to
the illegal values.
Step 4 Configure IOMMU TLB Invalidation Enable Register to enable the invalid operation. Among the way
to determine the invalid address is to get maximum valid bit and determine target address range by
target address AND mask address. The following figure shows the process.
IOMMU_TLB_IVLD_ADDR_REG,REG0 IOMMU_TLB_IVLD_ADDR_MASK_REG,REG1
31 11 0 31 Y 11 0
XXXXXXXXXXXXXXXXXXXX00 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 0 0 0 0 0 0 0 0 0 00 0 0 0
11≤Z≤31, Z≥Y
bit[Z+1]=1
bit[Z]~bit[11]=0
31 Z 11 0
Max range of target address,
X X X X X X X X X X X X X X X X X ???0 0 0 0 0 0 0 0 0 0 0 0
H_ADDR
For example:
a) When the value of IOMMU TLB Invalidation Address Mask Register is 0xFFFFF000 by default, the result
of AND is target address, that is, only target address is invalid.
b) When the value of IOMMU TLB Invalidation Address Mask Register is 0xFFFF0000, the value of IOMMU
TLB Invalidation Address Register is 0xEEEE1000, then the range of target address is from 0xEEEE0000 to
0xEEEEF000.
c) When the value of IOMMU TLB Invalidation Address Mask Register is 0xFFFFC000, the value of IOMMU
TLB Invalidation Address Register is 0xEEEE8000, then the range of target address is from 0xEEEE8000 to
0xEEEEB000.
d) When the value of IOMMU TLB Invalidation Address Mask Register is 0xFFFF8000, the value of IOMMU
TLB Invalidation Address Register is 0xEEEEC000, then the range of target address is from 0xEEEE8000 to
0xEEEEF000.
e) When the value of IOMMU TLB Invalidation Address Mask Register is 0xFFFFC000, the value of IOMMU
TLB Invalidation Address Register is 0xEEEE0000, then the range of target address is from 0xEEEE0000 to
0xEEEE3000.
Step 1 Set IOMMU TLB Invalidation Mode Select Register to 1 to select mode1;
Step 2 Set the starting address of invalid TLB by IOMMU TLB Invalidation Start Address Register, and set
the ending address of invalid TLB by IOMMU TLB Invalidation Start Address Register;
Step 3 Configure IOMMU TLB Invalidation Enable Register to enable invalid operation, then the related TLB
operation is invalidated.
Step 2 Set the address register that needs to be invalidated to IOMMU PC Invalidation Address Register
(the addresses need to be aligned with 1 MB);
Step 3 Configure IOMMU PC Invalidation Enable Register to enable the invalid operation. That is, the PTW
cache operation of a cacheline is invalidated.
Step 2 Set the starting address of invalid TLB by IOMMU PTW Invalidation Start Address Register, and set
the ending address of invalid TLB by IOMMU PC Invalidation Start Address Register;
Step 3 Configure IOMMU PC Invalidation Enable Register to enable invalid operation, then to invalid the
related PWM cache operation is completed.
31 10 9 2 1 0
Start address of Level2 page table Reserved 01
Bit[9:2]: Reserved;
31 12 7 4 1 0
Physical base address ACI 1
Bit[11:8]: Reserved;
Bit[7:4]: ACI, permission control index; correspond to permission control bit of IOMMU Domain Authority
Control Register;
Bit[3:2]: Reserved;
Bit[0]: Reserved
Permission Index
The read/write access control of series register such as IOMMU Domain Authority Control Register is as
follows.
The value of IOMMU Domain Authority Control Register is read-only by default. Other registers can configure
through system requirement. In address switch process, the corresponding relation between ACI and Domain
is as follows.
After enabled IOMMU Domain Authority Overwrite Register, the read/write control permission can override
all IOMMU Domain Authority Control Register.
Before the IOMMU module software reset operation, make sure IOMMU is never opened, or all bus operations
are completed, or DRAM and peripherals already open the corresponding switch, to shield the influence of
IOMMU reset.
Before opening the IOMMU address mapping function, the Translation Table Base Register should be correctly
configured, or all the masters are in the bypass state, or all the masters do not send the bus command.
Operating the register must close the address mapping function of IOMMU, that is, the
IOMMU_ENABLE_REG[0] is 0; or the bypass function of all masters is set to 1; or the state of the TX bus
command is none.
In the Flush operation, all TLB/Cache access will be suspended; but the operation entered the TLB will continue
to complete before the Flush starts.
For target virtual address, read and write the corresponding physical address data to make sure whether
IOMMU module address mapping function is normal. First, make sure to read or write, and then configure the
target virtual address or write data, then start to read or write function, check whether the results are as
expected after the operation is finished.
When PMU function is used for the first time, set IOMMU PMU Enable Register to enable statistics function;
when reading the relevant Register, clear the enable bit of IOMMU PMU Enable Register; when PMU function
is used next time, first IOMMU PMU Clear Register is set, after counter is cleared, set the enable bit of IOMMU
PMU Enable Register.
Given a Level2 page table administers continuous 4 KB address, if Micro TLB misses in continuous virtual
address, there may need to return a Level2 page table to hit from Macro TLB; but the hit number is not recorded
in the Macro TLB hit and Micro TLB hit related register. So the true hit rate calculation is as follows:
NOTE
Operating the register belongs to non-accurate timing sequence control function. That is, before the
function is valid, master operation will complete address mapping function, and any subsequent operation
will not perform address mapping.
It is suggested that master is in reset state or in no any bus operation before operating the register.
3.11.6.5 0x0044 IOMMU Write Buffer Control Register (Default Value: 0x0000_007F)
3.11.6.6 0x0048 IOMMU Out Of Order Control Register (Default Value: 0x0000_007F)
3.11.6.7 0x004C IOMMU 4KB Boundary Protect Control Register (Default Value: 0x0000_007F)
NOTE
When the virtual address sent by master is over the 4 KB boundary, 4 KB protection unit will split it into two
serial access.
3.11.6.8 0x0050 IOMMU Translation Table Base Register (Default Value: 0x0000_0000)
3.11.6.11 0x0080 IOMMU TLB Flush Enable Register (Default Value: 0x0000_0000)
Before flush starts, the operation that has entered TLB continues to complete.
Offset: 0x0080 Register Name: IOMMU_TLB_FLUSH_ENABLE_REG
Bit Read/Write Default/Hex Description
31:18 / / /
PC_FS
PTW Cache Flush
Clear PTW Cache
17 R/WAC 0x0 0: No clear operation or clear operation is completed
1: Enable clear operation
After the Flush operation is completed, the bit can clear
automatically.
MA_TLB_FS
Macro TLB Flush
16 R/WAC 0x0
Clear Macro TLB
0: No clear operation or clear operation is completed
3.11.6.12 0x0084 IOMMU TLB Invalidation Mode Select Register (Default Value: 0x0000_0000)
3.11.6.13 0x0088 IOMMU TLB Invalidation Start Address Register (Default Value: 0x0000_0000)
3.11.6.14 0x008C IOMMU TLB Invalidation End Address Register (Default Value: 0x0000_0000)
3.11.6.15 0x0090 IOMMU TLB Invalidation Address Register (Default Value: 0x0000_0000)
Operation:
1) Set the virtual address that needs to be operated in IOMMU_TLB_IVLD_ADDR_REG.
2) Set the mask of virtual address that needs to be operated in IOMMU_TLB_IVLD_ADDR_MASK_REG.
3) Write ‘1’ to IOMMU_TLB_IVLD_ENABLE_REG[0].
4) Read IOMMU_TLB_IVLD_ENABLE_REG[0], when it is ‘0’, it indicates that invalidation behavior is finished.
NOTE
After or before invalidation operation starts, there is no absolute relationship between the same address
switch operation and invalidation operation.
3.11.6.16 0x0094 IOMMU TLB Invalidation Address Mask Register (Default Value: 0x0000_0000)
3.11.6.17 0x0098 IOMMU TLB Invalidation Enable Register (Default Value: 0x0000_0000)
3.11.6.18 0x009C IOMMU PC Invalidation Mode Select Register (Default Value: 0x0000_0000)
3.11.6.20 0x00A4 IOMMU PC Invalidation Start Address Register (Default Value: 0x0000_0000)
3.11.6.22 0x00AC IOMMU PC Invalidation End Address Register (Default Value: 0x0000_0000)
3.11.6.23 0x00B0 IOMMU Domain Authority Control 0 Register (Default Value: 0x0000_0000)
Software can set 15 different permission control types in IOMMU_DM_AUT_CTRL_REG0–7. A default access
control type is DOMAIN0. The read/write operation of DOMAIN1–15 is unlimited by default.
Software needs to set the index of the permission control domain corresponding to the page table item in the
bit[7:4] of the Level2 page table, the default value is 0 (use domian0), that is, the read/write operation is not
controlled.
Setting REG_ARD_OVWT can mask the Domain control defined by IOMMU_DM_AUT_CTRL_REG0–7. All Level2
page table type are covered by the type of REG_ARD_OVWT. The read/write operation is permitted by default.
Offset: 0x00B0 Register Name: IOMMU_DM_AUT_CTRL0_REG
Bit Read/Write Default/Hex Description
31:30 / / /
DM1_M6_WT_AUT_CTRL
Domain1 write permission control for master6
29 R/W 0x0 0: The write-operation is permitted
1: The write-operation is prohibited
Note: The bit is not used.
DM1_M6_RD_AUT_CTRL
Domain1 read permission control for master6
28 R/W 0x0 0: The read-operation is permitted
1: The read-operation is prohibited
Note: The bit is not used.
DM1_M5_WT_AUT_CTRL
Domain1 write permission control for master5
27 R/W 0x0
0: The write-operation is permitted
1: The write-operation is prohibited
DM1_M5_RD_AUT_CTRL
Domain1 read permission control for master5
26 R/W 0x0
0: The read-operation is permitted
1: The read-operation is prohibited
DM1_M4_WT_AUT_CTRL
Domain1 write permission control for master4
25 R/W 0x0
0: The write-operation is permitted
1: The write-operation is prohibited
DM1_M4_RD_AUT_CTRL
Domain1 read permission control for master4
24 R/W 0x0
0: The read-operation is permitted
1: The read-operation is prohibited
DM1_M3_WT_AUT_CTRL
Domain1 write permission control for master3
23 R/W 0x0
0: The write-operation is permitted
1: The write-operation is prohibited
22 R/W 0x0 DM1_M3_RD_AUT_CTRL
3.11.6.24 0x00B4 IOMMU Domain Authority Control 1 Register (Default Value: 0x0000_0000)
3.11.6.25 0x00B8 IOMMU Domain Authority Control 2 Register (Default Value: 0x0000_0000)
3.11.6.26 0x00BC IOMMU Domain Authority Control 3 Register (Default Value: 0x0000_0000)
3.11.6.27 0x00C0 IOMMU Domain Authority Control 4 Register (Default Value: 0x0000_0000)
3.11.6.28 0x00C4 IOMMU Domain Authority Control 5 Register (Default Value: 0x0000_0000)
3.11.6.29 0x00C8 IOMMU Domain Authority Control 6 Register (Default Value: 0x0000_0000)
3.11.6.30 0x00CC IOMMU Domain Authority Control 7 Register (Default Value: 0x0000_0000)
3.11.6.31 0x00D0 IOMMU Domain Authority Overwrite Register (Default Value: 0x0000_0000)
Setting the REG_ARD_OVWT can mask the Domain control defined by IOMMU_DM_AUT_CTRL_REG0–7. All
the property of Level2 are covered by the property defined in REG_ARD_OVWT. Allow read and write for all by
default.
Offset: 0x00D0 Register Name: IOMMU_DM_AUT_OVWT_REG
Bit Read/Write Default/Hex Description
DM_AUT_OVWT_ENABLE
Domain write/read permission overwrite enable
31 R/W 0x0
0: Disable
1: Enable
30:14 / / /
M6_WT_AUT_OVWT_CTRL
Master6 write permission overwrite control
13 R/W 0x0 0: The write-operation is permitted
1: The write-operation is prohibited
Note: The bit is not used.
M6_RD_AUT_OVWT_CTRL
Master6 read permission overwrite control
12 R/W 0x0 0: The read-operation is permitted
1: The read-operation is prohibited
Note: The bit is not used.
M5_WT_AUT_OVWT_CTRL
Master5 write permission overwrite control
11 R/W 0x0
0: The write-operation is permitted
1: The write-operation is prohibited
M5_RD_AUT_OVWT_CTRL
Master5 read permission overwrite control
10 R/W 0x0
0: The read-operation is permitted
1: The read-operation is prohibited
M4_WT_AUT_OVWT_CTRL
9 R/W 0x0
Master5 write permission overwrite control
Invalid page table and permission error can not make one device or multi-devices in system work normally.
Permission error usually happens in MicroTLB. The error generates interrupt and waits for processing through
software.
Invalid page table usually happens in MacroTLB. The error can not influence the access of other devices. So the
error page table needs go back the way it comes, but the error should not be written in each level TLB.
Offset: 0x0100 Register Name: IOMMU_INT_ENABLE_REG
Bit Read/Write Default/Hex Description
31:21 / / /
DBG_PF_L2_IV_PT_EN.
Debug or Prefetch Invalid Page Table Enable
20 R/W 0x0
0: Mask interrupt
1: Enable interrupt
DBG_PF_PC_IV_L1_PT_EN.
Debug or Prefetch PTW Cache Invalid Level1 Page Table Enable
19 R/W 0x0
0: Mask interrupt
1: Enable interrupt
DBG_PF_DRAM_IV_L1_PT_EN.
Debug or Prefetch DRAM Invalid Level1 Page Table Enable
18 R/W 0x0
0: Mask interrupt
1: Enable interrupt
L2_PAGE_TABLE_INVALID_EN
Level2 page table invalid interrupt enable
17 R/W 0x0
0: Mask interrupt
1: Enable interrupt
L1_PAGE_TABLE_INVALID_EN
Level1 page table invalid interrupt enable
16 R/W 0x0
0: Mask interrupt
1: Enable interrupt
15:7 / / /
6 R/W 0x0 MICRO_TLB6_INVALID_EN
3.11.6.35 0x0110 IOMMU Interrupt Error Address 0 Register (Default Value: 0x0000_0000)
3.11.6.36 0x0114 IOMMU Interrupt Error Address 1 Register (Default Value: 0x0000_0000)
3.11.6.37 0x0118 IOMMU Interrupt Error Address 2 Register (Default Value: 0x0000_0000)
3.11.6.38 0x011C IOMMU Interrupt Error Address 3 Register (Default Value: 0x0000_0000)
3.11.6.39 0x0120 IOMMU Interrupt Error Address 4 Register (Default Value: 0x0000_0000)
3.11.6.40 0x0124 IOMMU Interrupt Error Address 5 Register (Default Value: 0x0000_0000)
3.11.6.41 0x0128 IOMMU Interrupt Error Address 6 Register (Default Value: 0x0000_0000)
3.11.6.42 0x0130 IOMMU Interrupt Error Address 7 Register (Default Value: 0x0000_0000)
3.11.6.43 0x0134 IOMMU Interrupt Error Address 8 Register (Default Value: 0x0000_0000)
3.11.6.44 0x0150 IOMMU Interrupt Error Data 0 Register (Default Value: 0x0000_0000)
3.11.6.45 0x0154 IOMMU Interrupt Error Data 1 Register (Default Value: 0x0000_0000)
3.11.6.46 0x0158 IOMMU Interrupt Error Data 2 Register (Default Value: 0x0000_0000)
3.11.6.47 0x015C IOMMU Interrupt Error Data 3 Register (Default Value: 0x0000_0000)
3.11.6.48 0x0160 IOMMU Interrupt Error Data 4 Register (Default Value: 0x0000_0000)
3.11.6.49 0x0164 IOMMU Interrupt Error Data 5 Register (Default Value: 0x0000_0000)
3.11.6.50 0x0168 IOMMU Interrupt Error Data 6 Register (Default Value: 0x0000_0000)
3.11.6.51 0x0170 IOMMU Interrupt Error Data 7 Register (Default Value: 0x0000_0000)
3.11.6.52 0x0174 IOMMU Interrupt Error Data 8 Register (Default Value: 0x0000_0000)
3.11.6.53 0x0180 IOMMU L1 Page Table Interrupt Register (Default Value: 0x0000_0000)
3.11.6.54 0x0184 IOMMU L2 Page Table Interrupt Register (Default Value: 0x0000_0000)
3.11.6.56 0x0194 IOMMU Virtual Address Data Register (Default Value: 0x0000_0000)
3.11.6.57 0x0198 IOMMU Virtual Address Configuration Register (Default Value: 0x0000_0000)
3.11.6.60 0x0230 IOMMU PMU Access Low 0 Register (Default Value: 0x0000_0000)
3.11.6.61 0x0234 IOMMU PMU Access High 0 Register (Default Value: 0x0000_0000)
3.11.6.62 0x0238 IOMMU PMU Hit Low 0 Register (Default Value: 0x0000_0000)
3.11.6.63 0x023C IOMMU PMU Hit High 0 Register (Default Value: 0x0000_0000)
3.11.6.64 0x0240 IOMMU PMU Access Low 1 Register (Default Value: 0x0000_0000)
3.11.6.65 0x0244 IOMMU PMU Access High 1 Register (Default Value: 0x0000_0000)
3.11.6.66 0x0248 IOMMU PMU Hit Low 1 Register (Default Value: 0x0000_0000)
3.11.6.67 0x024C IOMMU PMU Hit High 1 Register (Default Value: 0x0000_0000)
3.11.6.68 0x0250 IOMMU PMU Access Low 2 Register (Default Value: 0x0000_0000)
3.11.6.69 0x0254 IOMMU PMU Access High 2 Register (Default Value: 0x0000_0000)
3.11.6.70 0x0258 IOMMU PMU Hit Low 2 Register (Default Value: 0x0000_0000)
3.11.6.71 0x025C IOMMU PMU Hit High 2 Register (Default Value: 0x0000_0000)
3.11.6.72 0x0260 IOMMU PMU Access Low 3 Register (Default Value: 0x0000_0000)
3.11.6.73 0x0264 IOMMU PMU Access High 3 Register (Default Value: 0x0000_0000)
3.11.6.74 0x0268 IOMMU PMU Hit Low 3 Register (Default Value: 0x0000_0000)
3.11.6.75 0x026C IOMMU PMU Hit High 3 Register (Default Value: 0x0000_0000)
3.11.6.76 0x0270 IOMMU PMU Access Low 4 Register (Default Value: 0x0000_0000)
3.11.6.77 0x0274 IOMMU PMU Access High 4 Register (Default Value: 0x0000_0000)
3.11.6.78 0x0278 IOMMU PMU Hit Low 4 Register (Default Value: 0x0000_0000)
3.11.6.79 0x027C IOMMU PMU Hit High 4 Register (Default Value: 0x0000_0000)
3.11.6.80 0x0280 IOMMU PMU Access Low 5 Register (Default Value: 0x0000_0000)
3.11.6.81 0x0284 IOMMU PMU Access High 5 Register (Default Value: 0x0000_0000)
3.11.6.82 0x0288 IOMMU PMU Hit Low 5 Register (Default Value: 0x0000_0000)
3.11.6.83 0x028C IOMMU PMU Hit High 5 Register (Default Value: 0x0000_0000)
3.11.6.84 0x0290 IOMMU PMU Access Low 6 Register (Default Value: 0x0000_0000)
3.11.6.85 0x0294 IOMMU PMU Access High 6 Register (Default Value: 0x0000_0000)
3.11.6.86 0x0298 IOMMU PMU Hit Low 6 Register (Default Value: 0x0000_0000)
3.11.6.87 0x029C IOMMU PMU Hit High 6 Register (Default Value: 0x0000_0000)
3.11.6.88 0x02D0 IOMMU PMU Access Low 7 Register (Default Value: 0x0000_0000)
3.11.6.89 0x02D4 IOMMU PMU Access High 7 Register (Default Value: 0x0000_0000)
3.11.6.90 0x02D8 IOMMU PMU Hit Low 7 Register (Default Value: 0x0000_0000)
3.11.6.91 0x02DC IOMMU PMU Hit High 7 Register (Default Value: 0x0000_0000)
3.11.6.92 0x02E0 IOMMU PMU Access Low 8 Register (Default Value: 0x0000_0000)
3.11.6.93 0x02E4 IOMMU PMU Access High 8 Register (Default Value: 0x0000_0000)
3.11.6.94 0x02E8 IOMMU PMU Hit Low 8 Register (Default Value: 0x0000_0000)
3.11.6.95 0x02EC IOMMU PMU Hit High 8 Register (Default Value: 0x0000_0000)
3.11.6.96 0x0300 IOMMU Total Latency Low 0 Register (Default Value: 0x0000_0000)
3.11.6.97 0x0304 IOMMU Total Latency High 0 Register (Default Value: 0x0000_0000)
3.11.6.99 0x0310 IOMMU Total Latency Low 1 Register (Default Value: 0x0000_0000)
3.11.6.100 0x0314 IOMMU Total Latency High 1 Register (Default Value: 0x0000_0000)
3.11.6.102 0x0320 IOMMU Total Latency Low 2 Register (Default Value: 0x0000_0000)
3.11.6.103 0x0324 IOMMU Total Latency High 2 Register (Default Value: 0x0000_0000)
3.11.6.105 0x0330 IOMMU Total Latency Low 3 Register (Default Value: 0x0000_0000)
3.11.6.106 0x0334 IOMMU Total Latency High 3 Register (Default Value: 0x0000_0000)
3.11.6.108 0x0340 IOMMU Total Latency Low 4 Register (Default Value: 0x0000_0000)
3.11.6.109 0x0344 IOMMU Total Latency High 4 Register (Default Value: 0x0000_0000)
3.11.6.111 0x0350 IOMMU Total Latency Low 5 Register (Default Value: 0x0000_0000)
3.11.6.112 0x0354 IOMMU Total Latency High 5 Register (Default Value: 0x0000_0000)
3.11.6.114 0x0360 IOMMU Total Latency Low 6 Register (Default Value: 0x0000_0000)
3.11.6.115 0x0364 IOMMU Total Latency High 6 Register (Default Value: 0x0000_0000)
3.12 RTC
3.12.1 Overview
The Real Time Clock (RTC) is used to implement time counter and timing wakeup functions. The RTC can display
the year, month, day, week, hour, minute, second in real time. The RTC has the independent power to continue
to work in system power-off.
Provides a 16-bit counter for counting day, 5-bit counter for counting hour, 6-bit counter for counting
minute, 6-bit counter for counting second
Supports timing alarm, and generates interrupt and wakeup the external devices
CAUTION
The register configuration of RTC is AHB bus, it only can support word operation, not byte operation and half-
word operation.
VCC_PLL Domain(1.8V)
PLL_TOP
DCXO_CLK24M
1.8V
Analog_rtc_dcxo
Rc16m
Clk24m
32K XTAL Clk32k
DCXO 0.9V
RC16M
RTCVIO SPI
POR LDO 0.9V RTC 0.9V RTC SYSCPUS
Timer Logic Interface
GPIO
P_RESETB
P_NMI
P_TEST
P_CLK32K_FANOUT
Signal Description
X32KIN 32.768 kHz oscillator input
X32KOUT 32.768 kHz oscillator output
VCC-RTC RTC high voltage, generated via external power
AHBS1
SYSRTC_TOP
RTC_TOP_REG
SPI_MST
VDD_CPUS
X32KIN SPI_SLV
32K
crystal X32KOUT VCC-RTC
RTC VCC-RTC
DXIN
24M
crystal DXOUT
Alarm0_irq
CLK16M_RC_EN
LOSC_SRC_SEL
16M RC /32 /N 0
CLK32K
SYSTEM
EXT LOSC 1
RTC_SRC_SEL
0
/32 RTC
EXT_LOSC_EN
1
Debounce circuit
LOSC_OUT_SRC_SEL
00 RTC_32K_FANOUT
01 PAD
DCXO 24MDIV32K 10
LOSC
The LOSC has 2 clock sources: internal RC, external low frequency crystal. The LOSC selects the internal RC by
default, when the system starts, the LOSC can select by software the external low frequency crystal to provide
much accuracy clock. The clock accurate of the LOSC is related to the accurate of the external low frequency
crystal. Usually select 32.768 kHz crystal with ±20 ppm frequency tolerance. When using internal RC, the clock
can be changed by changing division ratio. When using external clock, the clock cannot be changed.
RTC
The clock sources of RTC can be selected by related switches, including 32K divided by internal 16 MHz RC, 32K
divided by external DCXO, and external 32.768 kHz crystal.
System 32K
The clock sources of system 32K are from external 32.768 kHz crystal and 32K divided by the internal 16 MHz
RC.
RTC_32K_FANOUT
The clock source of RTC_32K_FANOUT can select CLK32K, external 32.768 kHz crystal or 32K divided by external
DCXO.
Clock
1K Counter 3FA 3FB 3FC 3FD 3FE 3FF 0000 0001 0002 0003 0004 0005
Second
The 1K counter adds 1 on each rising edge of the clock. When the clock number reaches 0x3FF, 1K counter
starts to count again from 0, and the second counter adds 1. The step structure of 1 kHz counter is as follows.
Clock
1K
counter
Counter Range
Second 0 to 59
Minute 0 to 59
Hour 0 to 23
Day 0 to 65535 (The year, month, day need be transformed by software according to
day counter)
CAUTION
Because there is no error correction mechanism in the hardware, note that each counter configuration should
not exceed a reasonable counting range.
3.12.3.5 Alarm 0
The principle of alarm0 is a comparator. When RTC timer reaches the scheduled time, the RTC generates the
interrupt, or outputs low level signal by NMI pin to wakeup power management chip.
The RTC only generates one interrupt when RTC timer reached the scheduled day, hour, minute and second
counter, then the RTC needs to be set a new scheduled time, the next interrupt can be generated.
The RTC provides eight 32-bit general purpose register to store power-off information.
Because VCC-RTC always holds non-power-off state after VCC-RTC cold starts, when the system is in shutdown
or standby scene, the CPU can judge software process by the storing information.
3.12.3.7 RTC_VIO
The RTC module has a LDO, the input source of the LDO is VCC_RTC, the output of the LDO is RTC_VIO, the
value of RTC_VIO is adjustable, the RTC_VIO is mainly used for internal digital logic.
Standby or power-off scenario: Select external accurate 32K, or external calibrated 32K.
Step 1 Select clock source: Select clock source by the bit0 of LOSC_CTRL_REG, the clock source is the internal
RC oscillator by default. When the system starts, the clock source can be switched to the external 32K
oscillator by software.
Step 2 Auto switch: After enabled the bit[15:14] of LOSC_CTRL_REG, the RTC automatically switches clock
source to the internal oscillator when the external crystal could not output waveform, the switch
status can query by the bit[1] of LOSC_AUTO_SWT_STA_REG.
NOTE
If only configuring the bit[15] of LOSC_CTRL_REG, the clock source status bit cannot be changed after the auto
switch is valid, because the two functions are independent.
Step 1 Write time initial value: Write the current time to RTC_DAY_REG and RTC_HH_MM_SS_REG.
Step 2 After updated time, the RTC restarts to count again. The software can read the current time anytime.
NOTE
The RTC can only provide day counter, so the current day counter need be converted to year, month, day
and week by software.
Ensure the bit[8:7] of LOSC_CTRL_REG is 0 before the next time configuration is performed.
RTC_DAY_REG = 0x00000015;
RTC_HH_MM_SS_REG = 0x00070809; //0000 0000 000|0 0000(Hour) 00|00 0000(Minute) 00|00 0000(Second)
Read (RTC_DAY_REG);
Read (RTC_HH_MM_SS_REG);
3.12.4.3 Alarm0
Step 2 Set the counter comparator, write the count-down day, hour, minute, second number to
ALARM0_DAY_SET_REG and ALARM0_HH-MM-SS_SET_REG.
Step 3 Enable alarm0 function by writing ALARM0_ENABLE_REG, then the software can query alarm count
value in real time by ALARM0_DAY_SET_REG and ALARM0_HH-MM-SS_SET_REG. When the setting
time reaches, ALARM0_IRQ_STA_REG is set to 1 to generate interrupt.
Step 4 After enter the interrupt process, write ALARM0_IRQ_STA_REG to clear the interrupt pending, and
execute the interrupt process.
Step 5 Resume the interrupt and continue to execute the interrupted process.
Step 6 The power-off wakeup is generated via SoC hardware and PMIC, the software only needs to set the
pending condition of alarm0, and set ALARM_CONFIG_REG to 1.
NOTE
The offset addresses less than 0x0300 are in VDD_RTC power domain, and the offset addresses large than or
equal to 0x300 are in VDD_SYS power domain.
NOTE
If the bit[8:7] of LOSC_CTRL_REG is set, the RTC HH-MM-SS, DD and ALARM DD-HH-MM-SS register cannot be
written.
3.12.6.2 0x0004 LOSC Auto Switch Status Register (Default Value: 0x0000_0000)
3.12.6.3 0x0008 Internal OSC Clock Prescalar Register (Default Value: 0x0000_000F)
3.12.6.7 0x0024 Alarm 0 Counter Current Value Register (Default Value: UDF)
3.12.6.12 0x0060 32K Fanout Control Gating Register (Default Value: 0x0000_0000)
NOTE
General purpose register 0 to 7 value can be stored if the RTC-VIO is larger than 0.7 V.
3.12.6.19 0x01F4 VDD Off Gating Control Register (Default Value: 0x0000_0021)
14:12 / / /
VCCIO_DET_SPARE
Bit[7:5]: Reserved, default=0
Bit[4]: Bypass debounce circuit, defaule=0
Bit[3]: Enable control, defaule=0
0: Disable VCC-IO detection
11:4 R/W 0x2 1: Force the detection output
Bit[2:0]: Gear adjustment
000: Detection threshold is 2.5 V
001: Detection threshold is 2.6 V
010: Detection threshold is 2.7 V (default)
011: Detection threshold is 2.8 V
3.12.6.20 0x0204 Efuse High Voltage Power Switch Control Register (Default Value: 0x0000_0000)
3.12.6.21 0x0310 RTC SPI Clock Control Register (Default Value: 0x0000_0009)
Contents
4 Video and Graphics ................................................................................................................................................. 354
Figures
Figure 4-1 DE Block Diagram ............................................................................................................................................. 355
4.1 DE
The Display Engine (DE) is a hardware composer to transfer image layers from a local bus or a video buffer to
the LCD interface. The DE supports four overlay windows to blend, and supports image post-processing in the
video channel. The block diagram of DE is shown in Figure 4-1.
Four alpha blending channels for main display, three channels for aux display
DE
TCON0
RT-Mixer 0
MUX
M RT-Mixer 1
B TCON1
U
S
Write-Back
4.2 DI
The De-interlacer (DI) converts the interlaced input video frame to progressive video frame.
4.3 G2D
The Graphic 2D (G2D) engine is hardware accelerator for 2D graphic.
Supports multiple video formats 4:2:0, 4:2:2, 4:1:1 and multiple pixel formats (8/16/24/32 bits graphics
layer)
Supports 32-phase 8-tap horizontal anti-alias filter and 32-phase 4-tap vertical anti-alias filter
Supports horizontal and vertical flip, clockwise 0/90/180/270 degree rotate for normal buffer
Supports horizontal flip, clockwise 0/90/270 degree rotate for LBC buffer
4.4.1 Overview
The Video Decoding consists of Video Control Firmware (VCF) running on ARM processor and embedded
hardware Video Engine (VE). VCF gets the bitstream from topper software, parses bitstream, invokes the Video
Engine, and generates the decoding image sequence. The decoder image sequence is transmitted by the video
output controller to the display device under the control of the topper software.
Supports H.263 BP
Supports Xvid
Supports MJPEG
4.5.1 Overview
The JPGE is a high-performance JPEG encoder implemented by using hardware. It supports 64-megapixel
snapshot or HD MJPEG encoding.
Supports ISO/IEC 10918-1 (CCITT T.81) baseline process (DCT sequential) encoding
Encodes the pictures in the chrominance sampling format of YCbCr4:2:0 and YCbCr4:2:2
- Semi-planar YCbCr4:2:0
- Semi-planar YCbCr4:2:2
Supports configurable quantization tables for the Y component, Cb component and Cr component
respectively
- OSD overlaying with any size and at any position (within the size and position range of the picture)
Supports the MJPEG output bit rate ranging from 2 kbit/s to 60 Mbit/s
ARM
JPGE INT
The JPGE realizes various protocol processing with large computation such as OSD, level shift, DCT, quantization,
scanning, VLC encoding, and stream generation. The ARM software completes the encoding control processing
such as quantization table configuration and interrupt processing.
Before the JPGE starts encoding, the software allocates two types of buffers mainly in the external DDR SDRAM:
• Input picture buffer
The JPGE reads the source pictures to be encoded from this buffer during encoding. This buffer is generally
written by the Video Input Port module.
• Stream buffer
This buffer stores encoded streams. The JPGE writes streams to this buffer during encoding. This buffer is read
by software.
Contents
5 Video Output Interfaces.......................................................................................................................................... 365
Figures
Figure 5-1 TCON_LCD Block Diagram ................................................................................................................................ 366
Figure 5-5 LVDS Single Link JEDIA Mode Interface Timing................................................................................................ 374
Figure 5-6 LVDS Single Link NS Mode Interface Timing .................................................................................................... 374
Figure 5-7 LVDS Dual Link NS Mode Interface Timing ...................................................................................................... 375
Figure 5-10 The Data Timing of MIPI DSI Video Mode...................................................................................................... 378
Tables
Table 5-1 LCD External Signals .......................................................................................................................................... 366
Table 5-2 The Correspondence between LCD and RGB .................................................................................................... 367
5.1.1 Overview
The Timing Controller_LCD (TCON_LCD) is a module that processes video signals received from system through
a complicated arithmetic and then generates control signals and transmits them to the LCD panel driver IC.
CONTROL
VPLL
LOGIC
F RGB2
DATA
DE ASYNC FIFO1 R YUV Lcd data
FORMATTER
M (444)
LCD
HV TIMING Panel
The LCD external signals are used to connect to panel interface. The panel interface has various types.
For parallel RGB, the data of LCD is high-aligned. The correspondence is as follows.
CP- CP
-d bit
LCD0_HSYN
C IO1 HSYNC RD
HV I/F is also known as Sync + DE mode, which is widely used in TFT LCD module for PMP/MP4 applications.
Vertial Timing
VT
VBP
VSPW
Vsync
Hsync
D[23..0] Vertical invalid data period DH1 DH2 DHy Vertical invalid data period
Odd/Even field
VT
VSPW
Vsync
VBP
1//2
H
Hsync
D[23..0] Vertical invalid data period DH1 DH2 DHy Vertical invalid data period
Even field
HT
HBP
HSPW
Hsync
Tdclk
DCLK
DE
HT
HBP
HSPW
Hsync
Tdclk
DCLK
One Pixel
DE
In HV serial YUV output mode, its timing is BT656 compatible. SAV adds right before active area every line; EAV
adds right after active area every line.
P3 = V ⊕ H
P2 = F ⊕ H
P1 = F ⊕ V
P0 = F ⊕ V ⊕ H
D9 (MSB) D8 D7 D6 D5 D4 D3 D2 D1 D0
1 1 1 1 1 1 1 1 1 1
Preamble 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Status word 1 F V H P3 P2 P1 P0 0 0
The i8080 I/F LCD panel is most common interface for small size, low resolution LCD panels. The CPU control
signals are active low.
The following figure relationship between basic timing and CPU timing. WR is 180o delay of DCLK; CS is active
when pixel data is valid; RD is always set to 1; A1 is set by “LCD_CPUI/F”.
CS
A1
WR
RD
When CPU I/F is in IDLE state, it can generate WR/RD timing by setting “Lcd_CPUI/F”. The CS strobe is one DCLK
width, and the WR/RD strobe is half DCLK width.
Clock
RIN0+
R3 R2 G2 R7 R6 R5 R4 R3 R2 G2
RIN0-
RIN1+
G4 G3 B3 B2 G7 G6 G5 G4 G3 B3
RIN1-
RIN2+
RIN2- B5 B4 DE VS HS B7 B6 B5 B4 DE
RIN3+
RIN3- R1 R0 NA B1 B0 G1 G0 R1 R0 NA
Clock
RIN0+
R1 R0 G0 R5 R4 R3 R2 R1 R0 G0
RIN0-
RIN1+
G2 G1 B1 B0 G5 G4 G3 G2 G1 B1
RIN1-
RIN2+
RIN2- B3 B2 DE VS HS B5 B4 B3 B2 DE
RIN3+
RIN3- R7 R6 NA B7 B6 G7 G6 R7 R6 NA
ORXCLK+
ORXCLK-
RIN0+
OR0 OG0 OR5 OR4 OR3 OR2 OR1 OR0 OG0
RIN0-
RIN1+
OG1 OB1 OB0 OG5 OG4 OG3 OG2 OG1 OB1
RIN1-
RIN2+
RIN2- OB2 DE VS HS OB5 OB4 OB3 OB2 DE
RIN3+
RIN3- OR6 OB7 OB6 OG7 OG6 OR7 OR6
ORXCLK+
ORXCLK-
RIN0+
ER0 EG0 ER5 ER4 ER3 ER2 ER1 ER0 EG0
RIN0-
RIN1+
EG1 EB1 EB0 EG5 EG4 EG3 EG2 EG1 EB1
RIN1-
RIN2+
RIN2- EB2 DE VS HS EB5 EB4 EB3 EB2 DE
RIN3+
RIN3- ER6 EB7 EB6 EG7 EG6 ER7 ER6
The following table describes the clock sources of TCON_LCD. Table 5-9 describes the clock sources of
TCON_LCD.
Offset Value
0x400 { B0[7:0], G0[7:0], R0[7:0] }
0x404 { B1[7:0], G1[7:0], R1[7:0] }
...... ......
0x7FC { B255[7:0], G255[7:0], R255[7:0] }
NOTE
Rr, Rg, Rb, Gr, Gg, Gb, Br, Bg, Bb s13 (-16, 16)
R, G, B u8 [0-255]
Every 4 input pixels are as a unit. A unit is divided into 12 bytes. Output byte can select one of those 12 bytes.
Note that even line and odd line can be different, and output can be 12 bytes (4 pixels) or reduce to 6 bytes (2
pixels).
Input Output
In mode: 4 pixels
Out mode: 4 pixels/2 pixels eve0 eve1 eve2 eve3
D[7:3] D[7:3]
VSYNC BIT[3:0]
4BIT COUNTER
D[2:0] D2 D[1:0]=0
(1). When using MIPI DSI as display interface, the data clk of TCON needs be started firstly.
(2). When it is used with DSI video mode, the setting of block space needs to meet the following relationship.
HT
DRQ DRQ
ACTIVE HFP
DLY
DE SPACE
Line_set
lcd_dev[sel]->lcd_ctl.lcd_if = HV(Sync+DE);
NOTE
In parallel RGB mode, the displayed pixel clock (pixel_CLK) is required to be consistent with the
DCLK, the pixel_clk(pixel_clk=Ht*Vt*frame rate) is decided by external LCD.
Configure corresponding frequency by setting PLL_VIDEO0/1 register, and configure TCON LCD0
Clock register.
Configure internal frequency division of TCON_LCD. Based on clock source of TCON and DCLK clock
ratio, configure LCD_DCLK_REG[LCD_DCLK_DIV]. If using phase adjustment function,
LCD_DCLK_REG[LCD_DCLK_EN] needs be set, usually is 0xf. When the dclk1 and dclk2 in
LCD_DCLK_REG[LCD_DCLK_EN] are used, the value of LCD_DCLK_REG[LCD_DCLK_DIV] needs no less
than 6.
lcd_dev[sel]->lcd_dclk.dclk_en = en;
lcd_dev[sel]->lcd_dclk.dclk_div = div;
lcd_dev[sel]->lcd_basic0.x = x-1;
lcd_dev[sel]->lcd_basic0.y = y-1;
lcd_dev[sel]->lcd_basic1.ht = ht-1;
lcd_dev[sel]->lcd_basic1.hbp = hbp-1;
lcd_dev[sel]->lcd_basic2.vt = vt*2;
lcd_dev[sel]->lcd_basic2.vbp = vbp-1;
lcd_dev[sel]->lcd_basic3.hspw = hspw-1;
lcd_dev[sel]->lcd_basic3.vspw = vspw-1;
Set the corresponding data IO enable and control signal IO enable of LCD_IO_TRI_REG (reg0x8C) to
0 to start enable. Note that except the internal IO of TCON_LCD, the external GPIO mapping needs
to be set to LCD mode.
When some control signals require polarity reversal, it can realize by setting
LCD_IO_POL_REG.IO0~3_INV (reg0x88).
The LCD_GINT0_REG (reg0x4) controls interrupt mode and flag, and the LCD_GINT1_REG (reg0x8)
sets the interrupt line position of Line interrupt mode.
V interrupt:
lcd_dev[sel]->lcd_gint0.vb_en = 1;
Line interrupt:
lcd_dev[sel]->lcd_gint1.lcd_line_int_num = line;
lcd_dev[sel]->lcd_gint0.line_en = 1;
lcd_dev[sel]->lcd_ctl.lcd_en = 1;
lcd_dev[sel]->lcd_gctl.lcd_en = 1;
The serial RGB mode is consistent with parallel RGB mode, the main difference is the definition of clock and
the sequence of serial data. The difference is as follows.
lcd_dev[sel]->lcd_ctl.lcd_if = HV(Sync+DE);
In serial RGB mode, DCLK is the transfer clock of each byte data. In the same resolution, pixel_clk of
serial RGB is three times of its clock in parallel RGB, and ht,hbp,hspw own the same conversion
relation. When display is split into odd field and even field, LCD_BASE2_REG.VT needs not to be set
to the twice of the actual value.
lcd_dev[sel]->lcd_basic2.vt = vt;
lcd_dev[lcd_sel]->lcd_hv_ctl.srgb_seq_even = seq_even;
lcd_dev[lcd_sel]->lcd_hv_ctl.srgb_seq_odd = seq_odd;
The LVDS interface configuration process is similar to the parallel mode of HV mode, and adds the
digital/analog configuration of LVDS interface.
NOTE
In parallel mode, the displayed pixel clock (pixel_CLK) is required to be consistent with the DCLK,
pixel_clk=Ht*Vt*frame rate.
Release the LVDS reset of TCON LCD BUS GATING RESET register;
lcd_dev[sel]->lcd_dclk.dclk_en = en;
lcd_dev[sel]->lcd_dclk.dclk_div = 7;
Includes clock source select of module, LVDS link number, data mode and bit width configuration.
lcd_dev[sel]->lcd_lvds_ctl.lvds_link = link_num-1;
lcd_dev[sel]->lcd_lvds_ctl.lvds_mode = mode;
lcd_dev[sel]->lcd_lvds_ctl.lvds_bitwidth = bitwidth;
lcd_dev[sel]->lcd_lvds_ctl.lvds_clk_sel = clk_src;
lcd_dev[sel]->lcd_lvds_ctl.lvds_en = 1;
NOTE
If configuring the same source data output mode of dual link, except the reg0x84 register of
TCON_LCD0 needs be configured, the LCD_LVDS_IF_REG.LCD_LVDS_CLK_SEL,
LCD_LVDS_IF_REG.LCD_LVDS_LINK, LCD_LVDS_IF_REG.LCD_LVDS_MODE, and
LCD_LVDS_IF_REG.LCD_LVDS_BITWIDTH of the reg0x244 register need be configured.
NOTE
The TCON LCD0 PHY0 is controlled by COMBO_PHY_REG (reg0x1110, reg0x1114). The TCON LCD0
PHY1 is controlled by LCD_LVDS0_ANA_REG (reg0x220).
For PHY0:
For PHY1:
The LVDS analog configuration process is to start clock and data channel, and set the common mode
and differential mode voltage, and start module power.
lcd_dev[sel]->lcd_lvds_ana_ctl[lvds_num].bits.en_drvc = 1;
lcd_dev[sel]->lcd_lvds_ana_ctl[lvds_num].bits.diff_level = diff;
lcd_dev[sel]->lcd_lvds_ana_ctl[lvds_num].bits.com_level = com;
lcd_dev[sel]->lcd_lvds_ana_ctl[lvds_num].bits.dual_src = link_src;
lcd_dev[sel]->lcd_lvds_ana_ctl[lvds_num].bits.en_24M = 1;
lcd_dev[sel]->lcd_lvds_ana_ctl[lvds_num].bits.en_lvds = 1;
lcd_dev[sel]->lcd_lvds_ana_ctl[lvds_num].bits.en_mb = 1;
TRI Mode
Setup TRI INT or Setup TRI Mode Enable TRI FIFO and
Counter INT Params TRI mode
Select i8080 I/F and
Workmode
Setup V INT or Line
INT
AUTO Mode
Step 2 The step is the same as HV mode, but pulse adjustment function is invalid.
Step 3 The step is the same as HV mode. When using TRI mode, it is best to configure LCD timing parameters
in HV mode , or a handful of functions such as CMAP will not be able to apply.
Step 5 Select type and operating mode of i8080, the operating mode includes TRI mode and AUTO mode,
and the two operating modes are different.
Step 7 Set parameters of TRI mode, including block size, block space and block number.
NOTE
When output interface is parallel mode, then the setting value of block space parameter is not less
than 20.
When output interface is 2 cycle serial mode, then the setting value of block space parameter is not
less than 40.
When output interface is 3 cycle serial mode, then the setting value of block space parameter is not
less than 60.
When output interface is 4 cycle serial mode, then the setting value of block space parameter is not
less than 80.
Step 8 Set the tri interrupt or counter interrupt. When using the two interrupts, mainly in the interrupt
service function the tri start operation need be operated (the bit1 of LCD_CPU_IF_REG is set to"1").
If using TE trigger interrupt, you select the external input pin as a trigger signal, the 24-bit for offset
0x8C register is set to "1", to open up input of pad.
Step 11 Operate “tri start” operation (the bit1 of LCD_CPU_IF_REG is set to "1").
-------------------------------------------------------------------------------------------------------------------------------------------------
Step 6 Set and open V interrupt or Line interrupt, the step is the same as HV mode.
-------------------------------------------------------------------------------------------------------------------------------------------------
5.1.6.5 0x0014+ N*0x04 (N=0–5) LCD FRM Seed Register (Default Value: 0x0000_0000)
5.1.6.6 0x002C+ N*0x04 (N=0–3) LCD FRM Table Register (Default Value: 0x0000_0000)
5.1.6.15 0x0060 LCD CPU Panel Interface Register (Default Value: 0x0000_0000)
5.1.6.16 0x0064 LCD CPU Panel Write Data Register (Default Value: 0x0000_0000)
5.1.6.17 0x0068 LCD CPU Panel Read Data Register0 (Default Value: 0x0000_0000)
5.1.6.18 0x006C LCD CPU Panel Read Data Register1 (Default Value: 0x0000_0000)
5.1.6.24 0x0110+N*0x04 (N=0–10) LCD CEU Coefficient Register0 (Default Value: 0x0000_0000)
5.1.6.25 0x011C+N*0x10 (N=0–2) LCD CEU Coefficient Register1 (Default Value: 0x0000_0000)
5.1.6.26 0x0140+N*0x04 (N=0–2) LCD CEU Coefficient Register2 (Default Value: 0x0000_0000)
5.1.6.27 0x0160 LCD CPU Panel Trigger Register0 (Default Value: 0x0000_0000)
5.1.6.28 0x0164 LCD CPU Panel Trigger Register1 (Default Value: 0x0000_0000)
5.1.6.29 0x0168 LCD CPU Panel Trigger Register2 (Default Value: 0x0020_0000)
5.1.6.30 0x016C LCD CPU Panel Trigger Register3 (Default Value: 0x0000_0000)
5.1.6.31 0x0170 LCD CPU Panel Trigger Register4 (Default Value: 0x0000_0000)
5.1.6.32 0x0174 LCD CPU Panel Trigger Register5 (Default Value: 0x0000_0000)
5.1.6.33 0x0180 LCD Color Map Control Register (Default Value: 0x0000_0000)
5.1.6.34 0x0190 LCD Color Map Odd Line Register0 (Default Value: 0x0000_0000)
5.1.6.35 0x0194 LCD Color Map Odd Line Register1 (Default Value: 0x0000_0000)
5.1.6.36 0x0198 LCD Color Map Even Line Register0 (Default Value: 0x0000_0000)
5.1.6.37 0x019C LCD Color Map Even Line Register1 (Default Value: 0x0000_0000)
5.1.6.40 0x0228 LCD FSYNC Generate Control Register (Default Value: 0x0000_0000)
5.1.6.41 0x022C LCD FSYNC Generate Delay Register (Default Value: 0x0000_0000)
5.1.6.44 0x0238 LCD Slave Stop Position Register (Default Value: 0x0000_0000)
5.2 TCON TV
5.2.1 Overview
The Timing Controller_TV (TCON_TV) is a module that processes video signals received from systems using a
complicated arithmetic and then generates control signals and transmits them to the TV panel driver IC.
Rr, Rg, Rb, ,Gr, Gg, Gb, Br, Bg, Bb bool 0,1
R, G, B u10 [0-1023]
5.2.4.20 0x0304+N*0x0C (N=0–2) TV Fill Data Begin Register (Default Value: 0x0000_0000)
5.2.4.21 0x0308+N*0x0C (N=0–2) TV Fill Data End Register (Default Value: 0x0000_0000)
5.2.4.22 0x030C+N*0x0C (N=0–2) TV Fill Data Value Register (Default Value: 0x0000_0000)
5.3 TV Encoder
5.3.1 Overview
The TV Encoder (TVE) module is a highly programmable digital video encoder supporting worldwide video
standards Composite Video Broadcast Signal (CVBS).
digital analog
De-
Y noise
Peaking Y LPF1 DELAY Y
SIN Up DAC
CVBS
U LPF2 sample 10bit 216MSPS
De-flick
C
U DELAY
V LPF2
Burst
V DELAY COS
Plug Detect
DDFS
The TVE module requires one clock with 50% duty. Digital circuit and Analog circuit work by this clock. Mode
and Clock frequency is shown below.
Insert DAC
Pulse cycle
Detect Status Filter Detect Signal time
75R 75R
comparator
Pulse
Start
Ref voltage
Ref voltage
DAC outputs constant current, when insert, external load is 37.5Ω; when pull out, external load is 75Ω. The
method that comparator judges pin level can detect plug action.
Because plug action may exist jitter, then there need be a filter to filter jitter, the debounce time of filter is set
through the bit[3:0] of TV Encoder Auto Detection de-bounce Setting Register.
The pulse cycle time can be set through the bit[30:16] of TV Encoder Auto Detect Configuration Register1, the
pulse start time can be set through the bit[14:0] of TV Encoder Auto Detect Configuration Register1. The clock
sources of the two time are 32KHz clock.
Pulse amplitude can be set through the bit[9:0] of TV Encoder Auto Detect Configuration Register0.
EFUSE
BIAS Current
Generator
……
10 switch
Get Value (10 bits) to
control switchs
DAC Vout
37.5R
After FT, 10-bit calibration value is burned into efuse. Every time software can read the 10-bit calibration value
from efuse, to control BIAS current and BIAS current switch, then a specific BIAS current is generated to
calibrate maximum output voltage of DAC.
Operate TVE module by the following steps, Figure 5-17 shows the process diagram.
Step 1 Set CCU clock source for TVE, and release AHB bus, and module reset.
Step 2 Initial DAC amplitude value from efuse calibration value which has burned.
Step 3 Enable the plug-in detect function, and detect plug-in status every 200 ms.
Step 4 When the plug-in has detected, configure TVE module to output mode setting by application.
Delay 200 ms
No
Plug-In?
Yes
5.3.7.4 0x000C TV Encoder Notch and DAC Delay Register (Default Value: 0x0201_4924)
5.3.7.10 0x0030 TV Encoder Auto Detection Enable Register (Default Value: 0x0000_0000)
5.3.7.11 0x0034 TV Encoder Auto Detection Interrupt Status Register (Default Value: 0x0000_0000)
5.3.7.12 0x0038 TV Encoder Auto Detection Status Register (Default Value: 0x0000_0000)
5.3.7.13 0x003C TV Encoder Auto Detection Debounce Setting Register (Default Value: 0x0000_0000)
5.3.7.14 0x00F8 TV Encoder Auto Detection Configuration Register0 (Default Value: 0x0000_0000)
5.3.7.15 0x00FC TV Encoder Auto Detection Configuration Register1 (Default Value: 0x0000_0000)
5.3.7.16 0x0100 TV Encoder Color Burst Phase Reset Configuration Register (Default Value: 0x0000_0001)
5.3.7.18 0x0108 TV Encoder Notch Filter Frequency Register (Default Value: 0x0000_0002)
5.3.7.20 0x0110 TV Encoder Tint and Color Burst Phase Register (Default Value: 0x0000_0000)
5.3.7.23 0x011C TV Encoder Sync and VBI Level Register (Default Value: 0x0010_00F0)
5.3.7.25 0x0124 TV Encoder Video Active Line Register (Default Value: 0x0000_05A0)
5.3.7.26 0x0128 TV Encoder Video Chroma BW and CompGain Register (Default Value: 0x0000_0000)
5.3.7.32 0x0380 TV Encoder Low Pass Control Register (Default Value: 0x0000_0000)
5.3.7.33 0x0384 TV Encoder Low Pass Filter Control Register (Default Value: 0x0000_0000)
5.3.7.34 0x0388 TV Encoder Low Pass Gain Register (Default Value: 0x0000_0000)
5.3.7.35 0x038C TV Encoder Low Pass Gain Control Register (Default Value: 0x0000_0000)
5.3.7.36 0x0390 TV Encoder Low Pass Shoot Control Register (Default Value: 0x0000_0000)
5.3.7.37 0x0394 TV Encoder Low Pass Coring Register (Default Value: 0x0000_0000)
5.4.1 Overview
The Display Serial Interface is a high-speed interface between a host processor and peripheral devices that
adhere to MIPI Alliance specifications for mobile device interfaces. This DSI module is composed of a DSI
controller which is compliance with MIPI DSI specification V1.01 and a D-PHY module which is compliance with
MIPI DPHY specification V1.00.
Up to 4 lanes
Supports non-burst mode with sync pulse/sync event and burst mode
Supports pixel format: RGB888, RGB666, RGB666 loosely packed and RGB565
Supports continuous lane clock mode and non-continuous lane clock mode
Compliance with MIPI DCS v1.01, bidirectional communication in LP through data lane 0
Contents
6 Video Input Interfaces............................................................................................................................................. 467
Figures
Figure 6-1 CSIC Block Diagram .......................................................................................................................................... 467
Tables
Table 6-1 CSIC External Signals ......................................................................................................................................... 468
6.1 CSIC
6.1.1 Overview
The CMOS Sensor Interface Controller (CSIC) is an image or video data receiver, which can receive image or
video data via camera interface and store the data in memory directly.
- Supports dual data rate sample mode with pixel clock up to 148.5 MHz
DMA0
DC Input
GPIO Nmlcsi Memory
ncsi Parser0
DMA1
MSB LSB
MSB LSB
MSB LSB
MSB LSB
MSB
MSB LSB
MSB LSB
Offset in horizontal and vertical can be added when receiving image. Unit is pixel.
For YUV420 format, pixel unit is a YU/YV combination in YC line, and only a Y in Y line.
For Bayer and RAW format, pixel unit is a R/G/B single component.
Both horizontal and vertical flip are supported at the same time. This function is implemented in the process
of each FIFO writing data to memory, only flipping the data of separate FIFO, not changing component to FIFO
distribution.
For YUV format, a unit of Y0U0Y1V1 will parser and flip the Y component in one channel, and UV will be treated
as a whole. In planar output mode, U and V will be flipped separately. In UV combined output mode, UV will
be flipped as a whole. So, a sequence of Y1U0Y0V1 will be.
For Bayer_raw format, situation is much like. A GR/BG sequence will be changed to BG/RG. A unit of square
has four pixels.
For RGB565/RGB888, one unit of two/three bytes of component will be flipped with original sequence.
BIST_CS
2:0 R/W 0x0 000: Set when BK0 memory bist
001: Set when BK1 memory bist
Others: Reserved
6.1.7.5 0x0014 Parser NCSIC BT656 Header Configuration Register (Default Value:0x0302_0100)
6.1.7.7 0x0028 Parser Channel_0 Output Horizontal Size Register (Default Value:0x0500_0000)
6.1.7.8 0x002C Parser Channel_0 Output Vertical Size Register (Default Value:0x02D0_0000)
6.1.7.17 0x0128 Parser Channel_1 Output Horizontal Size Register (Default Value:0x0500_0000)
6.1.7.18 0x012C Parser Channel_1 Output Vertical Size Register (Default Value:0x02D0_0000)
6.1.7.27 0x0228 Parser Channel_2 Output Horizontal Size Register (Default Value:0x0500_0000)
6.1.7.28 0x022C Parser Channel_2 Output Vertical Size Register (Default Value:0x02D0_0000)
6.1.7.37 0x0328 Parser Channel_3 Output Horizontal Size Register (Default Value:0x0500_0000)
6.1.7.38 0x032C Parser Channel_3 Output Vertical Size Register (Default Value:0x02D0_0000)
6.1.7.46 0x0500 CSIC Parser NCSIC RX Signal0 Delay Adjust Register (Default Value:0x0000_0000)
6.1.7.47 0x0514 CSIC Parser NCSIC RX Signal5 Delay Adjust Register (Default Value:0x0000_0000)
6.1.7.48 0x0518 CSIC Parser NCSIC RX Signal6 Delay Adjust Register (Default Value:0x0000_0000)
6.1.8.5 0x0020 CSIC DMA FIFO 0 Output Buffer-A Address Register (Default Value:0x0000_0000)
6.1.8.6 0x0024 CSIC DMA FIFO 0 Output Buffer-A Address Result Register (Default Value:0x0000_0000)
6.1.8.7 0x0028 CSIC DMA FIFO 1 Output Buffer-A Address Register (Default Value:0x0000_0000)
6.1.8.8 0x002C CSIC DMA FIFO 1 Output Buffer-A Address Result Register (Default Value:0x0000_0000)
6.1.8.9 0x0030 CSIC DMA FIFO 2 Output Buffer-A Address Register (Default Value:0x0000_0000)
6.1.8.10 0x0034 CSIC DMA FIFO 2 Output Buffer-A Address Result Register (Default Value:0x0000_0000)
6.1.8.13 0x0040 CSIC DMA Video Input Timeout Threshold0 Register (Default Value:0x0000_0000)
6.1.8.14 0x0044 CSIC DMA Video Input Timeout Threshold1 Register(Default Value:0x0000_0000)
6.1.8.15 0x0048 CSIC DMA Video Input Timeout Counter Value Register (Default Value:0x0000_0000)
6.1.8.21 0x0060 CSIC DMA Frame Clock Counter Register (Default Value:0x0000_0000)
6.1.8.22 0x0064 CSIC DMA Accumulated and Internal Clock Counter Register (Default Value:0x0000_0000)
FIFO_THRS
11:0 R/W 0x400 When FIFO occupied memory exceed the threshold, dram
frequency can not change.
6.1.8.26 0x0080 CSIC DMA BUF Address FIFO0 Entry Register (Default Value:0x0000_0000)
6.1.8.27 0x0084 CSIC DMA BUF Address FIFO1 Entry Register (Default Value:0x0000_0000)
6.1.8.28 0x0088 CSIC DMA BUF Address FIFO2 Entry Register (Default Value:0x0000_0000)
6.1.8.30 0x0090 CSIC DMA BUF Address FIFO Content Register (Default Value:0x0000_0000)
6.1.8.31 0x0094 CSIC DMA Stored Frame Counter Register (Default Value:0x0000_0000)
6.2 TV Decoder
6.2.1 Overview
The Television Decoder (TVD) is an interface that transforms Composite Video Broadcast Signal (CVBS) or
component signal into YUV data.
Features:
NOTE
Analog Digital
Chroma
TVIN0
demodulate MBUS
Sync YC
TVIN1 clamp PGA ADC WB DMA
detect seperation
6.2.5.12 0x0008 TVD CLAMP & AGC CONTROL Register1 (Default Value: 0xA001_DD02)
6.2.5.13 0x000C TVD CLAMP & AGC CONTROL Register2 (Default Value: 0x8682_6440)
6.2.5.21 0x0030 TVD CHROMA LOCK CONTROL Register1 (Default Value: 0x0046_3201)
6.2.5.22 0x0034 TVD CHROMA LOCK CONTROL Register2 (Default Value: 0x21F0_7C1F)
2D_COMB_FILTER_MODE
2D Comb Filter Mode
For NTSC:
0000: 2D comb
0001~0010: Reserved
0011: 1D comb
0100~1000: Reserved
For PAL:
7:4 R/W 0x0
0000:2D comb filter1
0001: 1D comb filter1
0010: 2D comb filter2
0011: 1D comb filter2
0100: 1D comb filter3
0101: Reserved
0110: 2D comb filter3
0111~1000:Reserved
3D_COMB_FILTER_DIS
3D Comb Filter Disable
3 R/W 0x1
0: Enable 3D comb filter
1: Disable 3D comb filter
3D_COMB_FILTER_MODE
3D Comb_Filter Mode
000: 2D mode
2:0 R/W 0x1
001: 3D YC separation mode1
010~011: reserved
0100: 3D YC separation mode2
YC_DLY
YC Delay
0000: Y and C no delay
0001: Y delay 1 cycle to C
0010: Y delay 2 cycle to C
0011: Y delay 3 cycle to C
0100: Y delay 4 cycle to C
0101: Y delay 5 cycle to C
0110: Y delay 6 cycle to C
3:0 R/W 0x0
0111: Y delay 7 cycle to C
1000: Reserved
1001: Reserved
1010: Reserved
1011: C delay 5 cycle to Y
1100: C delay 4 cycle to Y
1101: C delay 3 cycle to Y
1110: C delay 2 cycle to Y
1111: C delay 1 cycle to Y
WB_FMT
WB Format
1 R/W 0x0
0: YUV420
1: YUV422
WB_EN
WB Enable
0 R/W 0x0
0: Disable
1: Enable
6.2.5.32 0x0080 TVD DMA Interrupt Control Register (Default Value: 0x0000_0000)
FIFO_Y_O_EN
FIFO Y Overflow Enable
5 R/W 0x0
0: IRQ disable
1: IRQ enable
FIFO_PB_O_EN
FIFO PB Overflow Enable
4 R/W 0x0
0: IRQ disable
1: IRQ enable
FIFO_PR_O_EN
FIFO PR Overflow Enable
3 R/W 0x0
0: IRQ disable
1: IRQ enable
2 / / /
UNLOCK_EN
Unlock Enable
1 R/W 0x0
0: IRQ disable
1: IRQ enable
LOCK_EN
Lock Enable
0 R/W 0x0
0: IRQ disable
1: IRQ enable
6.2.5.33 0x0090 TVD DMA Interrupt Status Register (Default Value: 0x0000_0000)
FIFO_C_U
FIFO C Underflow
7 R/W 0x0 0: FIFO work normal
1: FIFO underflow
Write 0x1 to clear this bit.
6 / / /
FIFO_Y_O
FIFO Y Overflow
5 R/W 0x0 0: FIFO work normal
1: FIFO overflow
Write 0x1 to clear this bit.
FIFO_C_O
FIFO C Overflow
4 R/W 0x0 0: FIFO work normal
1: FIFO overflow
Write 0x1 to clear this bit.
3:2 / / /
UNLOCK
Unlock
1 R/W 0x0
0: TVD status no change
1: TVD status change from lock to unlock
LOCK
Lock
0 R/W 0x0
0: TVD status no change
1: TVD status change from unlock to lock
CHROMA_PLL_LOCKED_TO_COLOR_BURST
Chroma Pll Locked To Color Burst
3 R 0x0
0: Unlock
1: Locked
V_LOCK
Vertical Lock
2 R 0x0
0: Unlock
1: Locked
H_LINE_LOCK
Horizontal line locked
1 R 0x0
0: Unlock
1: Locked
NO_SIG_DET
No Signal Detected
0 R 0x1
0 : Signal Detected
1 :No Signal Detected
Contents
7 Memory................................................................................................................................................................... 558
Figures
Figure 7-1 SMHC Block Diagram ....................................................................................................................................... 560
Figure 7-6 Data Packet Format for DDR in HS400 Mode .................................................................................................. 566
Figure 7-9 Phase Offset of Command and Data in SDR Mode .......................................................................................... 568
Figure 7-10 Phase Offset of Command and Data in DDR4 Mode (SMHC_NTSR[31] = 0) ................................................. 569
Figure 7-11 Phase Offset of Command and Data in DDR4 Mode ..................................................................................... 569
Figure 7-12 Phase Offset of Command and Data in DDR4 (2x Mode) (SMHC_NTSR[31] = 1) .......................................... 570
Tables
Table 7-1 SMHC Sub-blocks .............................................................................................................................................. 560
Table 7-7 Phase Offset of Command and Data in SDR Mode ........................................................................................... 569
Table 7-8 Phase Offset of Command and Data in DDR4 (2x) Mode ................................................................................. 570
7 Memory
7.2.1 Overview
The SMHC controls the read/write operations on the secure digital (SD) cards, multimedia cards (MMC), and
various extended devices that is based on the secure digital input/output (SDIO) protocol. The processor
provides three SMHC interfaces for controlling the SD cards, MMCs, and SDIO devices.
Supports Command Completion signals and interrupts to host processor, and Command Completion signal
disable feature
The SMHC0 controls the devices that comply with the Secure Digital Memory (SD mem-version 3.0)
The SMHC1 controls the device that complies with the protocol Secure Digital I/O (SDIO-version 3.0)
The SMHC2 controls the device that complies with the Multimedia Card (eMMC-version 5.0)
Maximum performance:
AHB
S
Y
Register CMD Path
N
C
CLK
CMD
SD/SDIO/eMMC
Data Path DATA0
...
Data RX
DMAC FIFO
Data TX
Sub-block Description
Used to configure the control signal for reading or writing the
Register
SD/SDIO/eMMC.
The DMA controller that controls the data transfer between the memory
DMAC
and SMHC.
A buffer for the data stream between the memory and the SMHC
FIFO
asynchronous clock domain.
Synchronizes the signals from the AHB clock domain to the SMHC clock
SYNC
domain.
CMD Path Sends commands to or receives commands from the SD/SDIO/eMMC.
Consists of Data TX and Data RX sub-modules. The Data TX sends data
Data Path blocks and the CRC codes to the SD/SDIO/eMMC. The Data RX receives
data blocks and the CRC codes from the SD/SDIO/eMMC.
The SMHC0/1 has 4 different clock sources. The SMHC2 has 5 different clock sources. You can select one of
them as the SMHC clock source. The following table describes the clock sources of the SMHC.
For clock setting, configurations, and gating information, refer to section 3.3 “CCU”.
JEDEC Standard – JESD84-44, Embedded Multimedia Card (eMMC) Card Product Standard
JEDEC Standard – JESD84-B45, Embedded Multimedia Card (eMMC) Electrical Standard (4.5 Device)
JEDEC Standard – JESD84-B50, Embedded Multimedia Card (eMMC) Electrical Standard (5.0)
The SMHC and SD/SDIO/eMMC contains the following interface buses: CLK, CMD, and DATA 1/4. During one
clock cycle, the SMHC can transmit one bit command with one or two bits data in 1-ch DATA mode, or four or
eight bits data in 4-ch DATA mode. The CMD is a bidirection channel for initializing the SD/SDIO/eMMC and
transmitting commands. It can work in both the open-drain mode and push-pull mode. The DATA is also a
bidirection channel. It works in the push-pull mode.
The register configures the signals for the read operation, and synchronize the signals to the SMHC clock
domain. Then the Data RX reads data from the SD/SDIO/eMMC via the CLK/CMD/DATA interface buses and
writes the data in the FIFO. After that, the DMAC transfers the data from the FIFO to the memory.
The register configures the signals for the write operation, and synchronize the signals to the SMHC clock
domain. Then the DMAC reads data from the memory and writes the data to the FIFO. After that, the Data TX
reads the data from the FIFO and writes the data to the SD/SDIO/eMMC via the CLK/CMD/DATA interface buses.
Data transfer over the SD/eMMC bus is based on command and data bitstreams that are initiated by a start bit
and terminated by a stop bit. There are three types of SD/eMMC packets: command token, response token,
and data packet.
Command Tokens
The command token starts an operation. A command is sent from the host to a device. It is transferred serially
on the CMD line. Command tokens have the following coding scheme:
0 1 Content CRC 1
Each command token has 48 bits, preceded by a start bit (‘0’) and succeeded by an end bit (‘1‘). To detect
transmission errors, each token is protected by CRC bits.
Response Tokens
After receiving a command, the card returns a 48-bit or 136-bit response based on the command type.
A response token is sent from the device to the host as an answer to a previously received command. It is
transferred serially on the CMD line.
Data Packets
Data can be transferred from the device to the host or vice versa. Data are transferred via the data lines.
NOTE
Start bit:
DAT6 0 b6 ... b6 b6 CRC 1
Always‘0’
LSBytes MSBytes
Block Length
DAT2 0 b6 b2 ... b6 b2 CRC 1
Block Length * 2
CLK
b15 b0 b0
0 b7 b7 b3 b3 1
DAT3 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 b6 b6 b2 b2 1
DAT2 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b5 b5 b1 b1 b15 b0 b0
DAT1 0 X ... (CRC ... (CRC (CRC
1 X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 b4 b4 b0 b0 1
DAT0 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
CLK
LSByte MSByte-1
LSByte+1 MSByte
b15 b0 b0
0 b7 b7 b7 b7 1
DAT7 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 b6 b6 b6 b6 1
DAT6 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b5 b5 b5 b5 b15 b0 b0
DAT5 0 X ... (CRC ... (CRC (CRC
1 X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 b4 b4 b4 b4 1
DAT4 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 b3 b3 b3 b3 1
DAT3 X ... (CRC ... (CRC (CRC X
(start) (odd) (odd) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 b2 b2 b2 b2 1
DAT2 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b1 b1 b1 b1 b15 b0 b0
DAT1 0 X ... (CRC ... (CRC (CRC 1 X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 b0 b0 b0 b0 1
DAT0 X ... (CRC ... (CRC (CRC X
(start) (odd) (even) (odd) (even) (end)
odd) odd) even)
NOTE
Start and end bits are only valid on the rising edge (“X” indicates “undefined”).
DS
LSByte MSByte-1
LSByte+1 MSByte
b15 b0 b0
0 0 b7 b7 b7 b7 1
DAT7 ... (CRC ... (CRC (CRC X
(start) (start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 0 b6 b6 b6 b6 1
DAT6 ... (CRC ... (CRC (CRC X
(start) (start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b5 b5 b5 b5 b15 b0 b0
DAT5 0 0 ... (CRC ... (CRC (CRC 1 X
(start) (start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 0 b4 b4 b4 b4 1
DAT4 (start) (start)
... (CRC ... (CRC (CRC X
(odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 0 b3 b3 b3 b3 1
DAT3 ... (CRC ... (CRC (CRC X
(start) (start) (odd) (odd) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 0 b2 b2 b2 b2 1
DAT2 ... (CRC ... (CRC (CRC X
(start) (start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b1 b1 b1 b1 b15 b0 b0
DAT1 0 0 ... (CRC ... (CRC (CRC 1 X
(start) (start) (odd) (even) (odd) (even) (end)
odd) odd) even)
b15 b0 b0
0 0 b0 b0 b0 b0 1
DAT0 X ... (CRC ... (CRC (CRC X
(start) (start) (odd) (even) (odd) (even) (end)
odd) odd) even)
NOTE
Start bits are valid when Data Strobe is High and Low.
End bits are only valid when Data Strobe is High (“X” indicates “undefined”).
Data transfers to or from the SD/eMMC card are done in blocks. Single and multiple block operations are widely
used during data transfer.
The following figure shows the single-block and multi-block read operation.
DAT Data Block CRC Data Block CRC Data Block CRC
Multi-Block Operation
The following figure shows the single-block and multi-block write operation.
Multi-Block Operation
The following table shows the bus speed modes supported by SD 3.0.
The following table shows the bus speed modes supported by eMMC 5.0.
You can configure the phase offset of the command and data by the SMHC_DRV_DL register.
SDR Mode
The following figure shows the phase offset of SDR command and data.
CLK CLK
DDR4 Mode
The following figure shows the phase offset of DDR4 command and data.
Figure 7-10 Phase Offset of Command and Data in DDR4 Mode (SMHC_NTSR[31] = 0)
CLK CLK
CMD DATA
CLK CLK
CMD DATA
The following figure shows the phase offset of DDR4 (2x mode) command and data.
Figure 7-12 Phase Offset of Command and Data in DDR4 (2x Mode) (SMHC_NTSR[31] = 1)
CLK CLK
CMD DATA
CLK CLK
CMD DATA
Table 7-8 Phase Offset of Command and Data in DDR4 (2x) Mode
The SMHC has an internal DMA controller (IDMAC) to transfer data between the host memory and SMHC port.
With a descriptor, the IDMAC can efficiently move data from the source to destination by automatically loading
the next DMA transfer arguments, which needs less CPU intervention. Before transferring data in the IDMAC,
the host driver should construct a descriptor list, configure arguments of every DMA transfer, and then launch
the descriptor and start the DMA.
The IDMAC has an interrupt controller. When enabled, it generates an interrupt to the HOST CPU in situations
such as data transmission is completed or some error is happened.
The IDMAC uses a descriptor with a chain structure, and each descriptor points to a unique buffer and the next
descriptor.
...
DES0 DES0 DES0
This figure illustrates the internal formats of a descriptor. The descriptor address must be aligned to the bus
width used for 32-bit buses. Each descriptor contains 16 bytes of control and status information.
DES0 corresponds to the [31:0] bits, DES1 corresponds to the [63:32] bits, DES2 corresponds to the [95:64] bits,
and DES3 corresponds the [127:96] bits in a descriptor.
There are two delay chains in SMHC: data strobe delay chain and sample delay chain.
Data strobe delay chain: used to generate delay to make proper timing between Data Strobe and data signals.
Sample delay chain: used to generate delay to make proper timing between the internal card clock signal and
data signals.
Each delay chain is made up with 64 delay cells. The delay time of one delay cell can be estimated through
delay chain calibration.
Step 1 Enable SMHC. In order to calibrate the delay chain by the operation registers in SMHC, the SMHC must
be enabled through SMHC Bus Gating Reset Register and SMHCx Clock Register.
Step 2 Configure a proper clock for SMHC. The delay chain calibration is based on the clock for SMHC from
Clock Control Unit (CCU). The delay chain calibration is an internal function in SMHC and needs no
devices. So it is unnecessary to open the clock signal for devices. The recommended clock frequency
is 200 MHz.
Step 3 Set proper initial delay value. Writing 0xA0 to delay control register enables Delay Software Enable
(bit[7]) and sets initial delay value 0x20 to Delay chain (bit[5:0]). Then write 0x0 to delay control
register to clear the value.
Step 4 Write 0x8000 to delay control register to start calibrating the delay chain.
Step 5 Wait until the flag (bit14 in delay control register) of calibration done is set. The number of delay cells
is shown at bit[13:8] in delay control register. The delay time generated by these delay cells is equal
to the cycle of the SMHC clock nearly. This value is the result of calibration.
Step 6 Calculate the delay time of one delay cell according to the cycle of the SMHC clock and the result of
calibration.
Before data and commands are exchanged between a card and the SMHC, the SMHC needs to be initialized.
Follow the steps below to initialize the SMHC:
Step 1 Configure the corresponding GPIO register as an SMHC by Port Controller module; reset clock by
writing 1 to SMHC_BGR_REG[SMHCx_RST], and open clock gating by writing 1 to
SMHC_BGR_REG[SMHCx_GATING]; select clock sources and set the division factor by configuring the
SMHCx_CLK_REG (x = 0, 1) register.
Step 2 Configure SMHC_CTRL to reset the FIFO and controller, and enable the global interrupt; configure
SMHC_INTMASK to 0xFFCE to enable normal interrupts and error abnormal interrupts, and then
register the interrupt function.
Step 3 Configure SMHC_CLKDIV to open clock for devices; configure SMHC_CMD as the change clock
command (for example 0x80202000); send the update clock command to deliver clocks to devices.
Step 1 Write 0x1 to SMHC_CTRL[DMA_RST] to reset the internal DMA controller; write 0x82 to
SMHC_IDMAC to enable the IDMAC interrupt and configure AHB master burst transfers; configure
SMHC_IDIE to enable the transfer interrupt, receive interrupt, and abnormal interrupt.
Step 2 Configure SMHC_FIFOTH to determine the burst size and TX/RX trigger level. For example, if
SMHC_FIFOTH is configured as 0x300F00F0, it indicates the burst size is 16, TX_TL is 15, and RX_TL is
240. Configure SMHC_DLBA to determine the start address of the DMA descriptor.
Step 3 To write one block data to sector1, configure SMHC_BYTCNT[BYTE_CNT] to 0x200 and configure the
descriptor according to the data size; set the data sector address of CMD24 (Single Data Block Write)
to 0x1, write 0x80002758 to SMHC_CMD, and send CMD24 command to write data to the device.
Step 4 Check whether SMHC_RINTSTS[CC] is 1. If yes, the command is sent successfully; otherwise, continue
to wait until timeout, and then exit the process.
Step 5 Check whether SMHC_IDST[TX_INT] is 1. If yes, the data transfer for writing DMA is completed. Write
0x337 to SMHC_IDST to clear the interrupt flag. Otherwise, continue to wait until timeout, and then
exit the process.
Step 6 Check whether SMHC_RINTSTS[DTC] is 1. If yes, the data transfer and CMD24 writing operations are
completed. Otherwise, abnormity exists. Read SMHC_RINTSTS and SMHC_STATUS to query the
existing abnormity.
Step 7 Send CMD13 command to query whether the device writing operation is completed and returns to
the idle status. For example, device RCA is 0x1234, first set SMHC_CMDARG to 0x12340000, write
0x8000014D to SMHC_CMD, go to step4 to ensure command transfer completed, and then check
whether the highest bit of SMHC_RESP0 (CMD13 response) is 1. If yes, the device is in the idle status,
and the next command can be sent. Otherwise, the device is in the busy status. Continue to send
CMD13 to wait for the device to enter the idle status until timeout.
Step 1 Write 0x1 to SMHC_CTRL[DMA_RST] to reset the internal DMA controller; write 0x82 to
SMHC_IDMAC to enable the IDMAC interrupt and configure AHB master burst transfers; configure
SMHC_IDIE to enable the transfer interrupt, receive interrupt, and abnormal interrupt.
Step 2 Configure SMHC_FIFOTH to determine the burst size and TX/RX trigger level. For example, if
SMHC_FIFOTH is configured as 0x300F00F0, it indicates the burst size is 16, TX_TL is 15, and RX_TL is
240. Configure SMHC_DLBA to determine the start address of the DMA descriptor.
Step 3 To read one block data from sector1, configure SMHC_BYTCNT[BYTE_CNT] to 0x200 and configure the
descriptor according to the data size; set the data sector address of CMD17 command (Single Data
Block Read) to 0x1, write 0x80002351 to SMHC_CMD, and send CMD17 command to read data from
the device to DRAM/SRAM.
Step 4 Check whether SMHC_RINTSTS[CC] is 1. If yes, the command is sent successfully; otherwise, continue
to wait until timeout, and then exit the process.
Step 5 Check whether SMHC_IDST[RX_INT] is 1. If yes, the data transfer for writing DMA is completed. Write
0x337 to SMHC_IDST to clear the interrupt flag. Otherwise, continue to wait until timeout, and then
exit the process.
Step 6 Check whether SMHC_RINTSTS[DTC] is 1. If yes, data transfer and CMD17 reading operation are
completed. Otherwise, abnormity exists. Read SMHC_RINTSTS and SMHC_STATUS to query the
existing abnormity.
Step 1 Write 0x1 to SMHC_CTRL[DMA_RST] to reset the internal DMA controller; write 0x82 to
SMHC_IDMAC to enable the IDMAC interrupt and configure AHB master burst transfers; configure
SMHC_IDIE to enable the transfer interrupt, receive interrupt, and abnormal interrupt.
Step 2 Configure SMHC_FIFOTH to determine the burst size and TX/RX trigger level. For example, if
SMHC_FIFOTH is configured as 0x300F00F0, it indicates the burst size is 16, TX_TL is 15, and RX_TL is
240. Configure SMHC_DLBA to determine the start address of the DMA descriptor.
Step 3 To write three blocks of data to sectors begin with sector0, configure SMHC_BYTCNT[BYTE_CNT] to
0x600 and configure the descriptor according to the data size; set the data sector address of CMD25
command (Multiple Data Blocks Write) to 0x0, write 0x80003759 to SMHC_CMD, and send CMD25
command to read data from the device to DRAM/SRAM.
Step 4 Check whether SMHC_RINTSTS[CC] is 1. If yes, the command is sent successfully; otherwise, continue
to wait until timeout, and then exit the process.
Step 5 Check whether SMHC_IDST[RX_INT] is 1. If yes, the data transfer for writing DMA is completed. Write
0x337 to SMHC_IDST to clear the interrupt flag. Otherwise, continue to wait until timeout, and then
exit the process.
Step 6 Check whether SMHC_RINTSTS[ACD] and SMHC_RINTSTS[DTC] are both 1. If yes, the data transfer,
CMD12 transfer, and CMD25 writing operations are completed. Otherwise, abnormity exists. Read
SMHC_RINTSTS and SMHC_STATUS to query the existing abnormity.
Step 7 Send CMD13 command to query whether the device writing operation is completed and returns to
the idle status. For example, device RCA is 0x1234, first set SMHC_CMDARG to 0x12340000, write
0x8000014D to SMHC_CMD, go to step4 to ensure command transfer completed, and then check
whether the highest bit of SMHC_RESP0 (CMD13 response) is 1. If yes, the device is in the idle status,
and the next command can be sent. Otherwise, the device is in the busy status. Continue to send
CMD13 to wait for the device to enter the idle status until timeout.
Step 1 Write 0x1 to SMHC_CTRL[DMA_RST] to reset the internal DMA controller; write 0x82 to
SMHC_IDMAC to enable the IDMAC interrupt and configure AHB master burst transfers; configure
SMHC_IDIE to enable the transfer interrupt, receive interrupt, and abnormal interrupt.
Step 2 Configure SMHC_FIFOTH to determine the burst size and TX/RX trigger level. For example, if
SMHC_FIFOTH is configured as 0x300F00F0, it indicates the burst size is 16, TX_TL is 15, and RX_TL is
240. Configure SMHC_DLBA to determine the start address of the DMA descriptor.
Step 3 To read three blocks of data from sectors begin with sector0, configure SMHC_BYTCNT[BYTE_CNT] to
0x600 and configure the descriptor according to the data size; set the data sector address of CMD18
command (Multiple Data Blocks Read) to 0x0, write 0x80003352 to SMHC_CMD, and send CMD18
command to read data to the device. When the data transfer is completed, CMD12 will be sent
automatically.
Step 4 Check whether SMHC_RINTSTS[CC] is 1. If yes, the command is sent successfully; otherwise, continue
to wait until timeout, and then exit the process.
Step 5 Check whether SMHC_IDST[RX_INT] is 1. If yes, the data transfer for writing DMA is completed. Write
0x337 to SMHC_IDST to clear the interrupt flag. Otherwise, continue to wait until timeout, and then
exit the process.
Step 6 Check whether SMHC_RINTSTS[ACD] and SMHC_RINTSTS[DTC] are both 1. If yes, data transfer,
CMD12 transfer, and CMD18 reading operation are completed. Otherwise, abnormity exists. Read
SMHC_RINTSTS and SMHC_STATUS to query the existing abnormity.
Step 1 Write 0x1 to SMHC_CTRL[DMA_RST] to reset the internal DMA controller; write 0x82 to
SMHC_IDMAC to enable the IDMAC interrupt and configure AHB master burst transfers; configure
SMHC_IDIE to enable the transfer interrupt, receive interrupt, and abnormal interrupt.
Step 2 Configure SMHC_FIFOTH to determine the burst size and TX/RX trigger level. For example, if
SMHC_FIFOTH is configured as 0x300F00F0, it indicates the burst size is 16, TX_TL is 15, and RX_TL is
240. Configure SMHC_DLBA to determine the start address of the DMA descriptor.
Step 3 To write three blocks of data, configure SMHC_CMDARG to 0x3 to specify the number of data blocks
as three. Then write 0x80000157 to SMHC_CMD to send the CMD23 command. Check whether
SMHC_RINTSTS[CC] is 1. If yes, the command is sent successful; otherwise, continue to wait until
timeout, and then exit the process.
Step 4 Configure SMHC_BYTCNT[BYTE_CNT] to 0x600 and configure the descriptor according to the data size;
set the data sector address of CMD25 command (Multiple Data Blocks Write) to 0x0, write 0x80002759
to SMHC_CMD, and send CMD25 command to write data to the device.
Step 5 Check whether SMHC_RINTSTS[CC] is 1. If yes, the command is sent successful; otherwise, continue
to wait until timeout, and then exit the process.
Step 6 Check whether SMHC_IDST[TX_INT] is 1. If yes, the data transfer for writing DMA is completed. Write
0x337 to SMHC_IDST to clear the interrupt flag. Otherwise, continue to wait until timeout, and then
exit the process.
Step 7 Check whether SMHC_RINTSTS[DTC] is 1. If yes, the data transfer and CMD25 writing operations are
completed. Otherwise, abnormity exists. Read SMHC_RINTSTS and SMHC_STATUS to query the
existing abnormity.
Step 8 Send CMD13 command to query whether the device writing operation is completed and returns to
the idle status. For example, device RCA is 0x1234, first set SMHC_CMDARG to 0x12340000, write
0x8000014D to SMHC_CMD, go to step4 to ensure command transfer completed, and then check
whether the highest bit of SMHC_RESP0 (CMD13 response) is 1. If yes, the device is in the idle status,
and the next command can be sent. Otherwise, the device is in the busy status. Continue to send
CMD13 to wait for the device to enter the idle status until timeout.
Step 1 Write 0x1 to SMHC_CTRL[DMA_RST] to reset the internal DMA controller; write 0x82 to
SMHC_IDMAC to enable the IDMAC interrupt and configure AHB master burst transfers; configure
SMHC_IDIE to enable the transfer interrupt, receive interrupt, and abnormal interrupt.
Step 2 Configure SMHC_FIFOTH to determine the burst size and TX/RX trigger level. For example, if
SMHC_FIFOTH is configured as 0x300F00F0, it indicates the burst size is 16, TX_TL is 15, and RX_TL is
240. Configure SMHC_DLBA to determine the start address of the DMA descriptor.
Step 3 To read three blocks of data, configure SMHC_CMDARG to 0x3 to specify the number of data blocks
as three. Then write 0x80000157 to SMHC_CMD to send the CMD23 command. Check whether
SMHC_RINTSTS[CC] is 1. If yes, the command is sent successful; otherwise, continue to wait until
timeout, and then exit the process.
Step 4 Configure SMHC_BYTCNT[BYTE_CNT] to 0x600 and configure the descriptor according to the data size;
set the data sector address of CMD18 (Multiple Data Blocks Read) to 0x0, write 0x80002352 to
SMHC_CMD, and send CMD18 command to read data from device to DRAM/SRAM.
Step 5 Check whether SMHC_RINTSTS[CC] is 1. If yes, the command is sent successful; otherwise, continue
to wait until timeout, and then exit the process.
Step 6 Check whether SMHC_IDST[TX_INT] is 1. If yes, the data transfer for writing DMA is completed. Write
0x337 to SMHC_IDST to clear the interrupt flag. Otherwise, continue to wait until timeout, and then
exit the process.
Step 7 Check whether SMHC_RINTSTS[DTC] is 1. If yes, the data transfer and CMD18 writing operations are
completed. Otherwise, abnormity exists. Read SMHC_RINTSTS and SMHC_STATUS to query the
existing abnormity.
7.2.6.14 0x0034 SMHC Masked Interrupt Status Register (Default Value: 0x0000_0000)
7.2.6.15 0x0038 SMHC Raw Interrupt Status Register (Default Value: 0x0000_0000)
7.2.6.17 0x0040 SMHC FIFO Water Level Register (Default Value: 0x000F_0000)
7.2.6.19 0x0048 SMHC Transferred Byte Count Register 0 (Default Value: 0x0000_0000)
7.2.6.20 0x004C SMHC Transferred Byte Count Register 1 (Default Value: 0x0000_0000)
7.2.6.21 0x0054 SMHC CRC Status Detect Control Register (Default Value: 0x0000_0003)
7.2.6.22 0x0058 SMHC Auto Command 12 Argument Register (Default Value: 0x0000_FFFF)
7.2.6.23 0x005C SMHC New Timing Set Register (Default Value: 0x8171_0000)
7.2.6.26 0x0084 SMHC Descriptor List Base Address Register (Default Value: 0x0000_0000)
7.2.6.28 0x008C SMHC IDMAC Interrupt Enable Register (Default Value: 0x0000_0000)
7.2.6.29 0x0100 SMHC Card Threshold Control Register (Default Value: 0x0000_0000)
7.2.6.30 0x0104 SMHC Sample FIFO Control Register (Default Value: 0x0000_0006)
7.2.6.31 0x0108 SMHC Auto Command 23 Argument Register (Default Value: 0x0000_0000)
7.2.6.32 0x010C SMHC eMMC4.5 DDR Start Bit Detection Control Register (Default Value: 0x0000_0000)
7.2.6.35 0x0140 SMHC Drive Delay Control Register (Default Value: 0x0001_0000)
7.2.6.36 0x0144 SMHC Sample Delay Control Register (Default Value: 0x0000_2000)
7.2.6.37 0x0148 SMHC Data Strobe Delay Control Register (Default Value: 0x0000_2000)
7.2.6.38 0x014C SMHC HS400 New Timing Delay Control Register (Default Value: 0x0000_8000)
Contents
8 Audio ....................................................................................................................................................................... 615
Figures
Figure 8-1 I2S/PCM Interface System Block Diagram ....................................................................................................... 616
Figure 8-27 Audio Codec Analog Part Reset System ......................................................................................................... 729
Tables
Table 8-1 I2S/PCM External Signals .................................................................................................................................. 617
Table 8-4 Proper MCLK Values with Different Fsin and Fsout .......................................................................................... 622
Table 8-14 The Corresponding Relation between Different System Clock and Sample Ratio .......................................... 701
8 Audio
8.1 I2S/PCM
8.1.1 Overview
The I2S/PCM controller is designed to transfer streaming audio-data between the system memory and the
codec chip. The controller supports standard I2S format, Left-justified mode format, Right-justified mode
format, PCM mode format, and TDM mode format.
Two I2S/PCM external interfaces (I2S1, I2S2) for connecting external power amplifier and MIC ADC
- Left-justified, Right-justified, PCM mode, and Time Division Multiplexing (TDM) format
- Programmable PCM frame width: 1 BCLK width (short frame) and 2 BCLKs width (long frame)
- 128 depth x 32-bit width TXFIFO and 64 depth x 32-bit width RXFIFO
- Clock up to 24.576 MHz Data Output of I2S/PCM in Master mode (Only if the IO PAD and Peripheral
I2S/PCM satisfy Timing Parameters)
- Up to 16 channels (fs = 48 kHz) which has adjustable width from 8-bit to 32-bit
The following figure shows the functional block diagram of the I2S/PCM interface.
PLL_AUDIO
Register
Clock
Divider
APB MCLK
I/F 128*32-bits ASRC I2S BCLK
TXFIFO Engine M
S
U LRCK
Y
X
N
DOUT
64*32-bits C PCM PCM
RXFIFO Codec Engine DIN
DMA & INT
PCM interface
The following figure shows the typical application of the I2S/PCM interface.
I2S
sd_out
I2S_TX
BCLK_out
LRCK_out
External I2S
BCLK_in CMU
LRCK_in
sd_in
I2S_RX
The I2S/PCM interface system integrates one I2S_TX and one I2S_RX.
When the I2S works in the master mode, the external I2S module provides BCLK_in and LRCK_in for the
clock management unit (CMU), and the I2S_TX and I2S_RX work with the two external clocks.
When the I2S works in the slave mode, the CMU provides clocks BCLK_out and LRCK_out for the external
I2S module, and the I2S_TX and I2S_RX work with the internal clocks.
The following table describes the external signals of the I2S/PCM interface.
LRCK and BCLK are bidirectional I/O. When the I2S/PCM interface works in the Master mode, LRCK and BCLK
are output pins. When the I2S/PCM interface works in the Slave mode, LRCK and BCLK are input pins.
MCLK is an output pin for external devices. DOUT are the serial data output pins and DIN are the serial data
input pins. For details about General Purpose I/O port, refer to section 9.7 “GPIO”.
The following table describes the clock sources for I2S/PCM. For clock setting, configurations, and gating
information, refer to section 3.3 “CCU”.
The I2S/PCM supports standard I2S mode, Left-justified I2S mode, Right-justified I2S mode, PCM mode, and
TDM mode. The software can select the modes by setting I2S/PCM_CTL. The following figures describe the
waveforms for SYNC, BCLK, DOUT, and DIN in different modes.
Each sampling period contains an LRCK. The low level of LRCK is the left channel corresponding to the even
slots, and the high level is the right channel corresponding to the odd slots. Each slot is the sampling point of a
mono channel. The sampling period can support the transmission of 2/4/8/16 slots. The BCLK corresponds to
the serial data bit.
DOUT/DIN 16 Slots 0 2 4 12 14 1 3 5 13 15
DOUT/DIN 8 Slots 0 2 4 6 1 3 5 7
m Slot m = 0–15
DOUT/DIN 4 Slots 0 2 1 3
1 / fs
LRCK Left Channel Right Channel
BCLK
DOUT/DIN 16 Slots 0 2 4 12 14 1 3 5 13 15
DOUT/DIN 8 Slots 0 2 4 6 1 3 5 7
m Slot m = 0–15
DOUT/DIN 4 Slots 0 2 1 3
DOUT/DIN 16 Slots 0 2 4 12 14 1 3 5 13 15
DOUT/DIN 8 Slots 0 2 4 6 1 3 5 7
DOUT/DIN 2 Slots 0 1
n-1 n-2 …
MSB Sample LSB
LRCK
(Long Frame)
BCLK
DOUT/DIN 16 Slots 0 1 2 3 4 5 6 7 14 15
DOUT/DIN 8 Slots 0 1 2 3 4 5 6 7
DOUT/DIN 4 Slots 0 1 2 3
m Slot m = 0–15
DOUT/DIN 2 Slots 0 1
n-1 n-2 … 1 0 Sample
DOUT/DIN 1 Slots 0 MSB LSB
LRCK
(Short Frame)
BCLK
DOUT/DIN 16 Slots 0 1 2 3 4 5 6 7 14 15
DOUT/DIN 8 Slots 0 1 2 3 4 5 6 7
DOUT/DIN 4 Slots 0 1 2 3
m Slot m = 0–15
DOUT/DIN 2 Slots 0 1
n-1 n-2 … 1 0 Sample
MSB LSB
DOUT/DIN 1 Slots 0
The 4-wire DIN has 64 slots, each wire DIN has 16 slots. However, only 16 slots are valid and act as the RX
channels.
The following table shows the relationship between the slot id and encoder.
DIN0 Slot ID 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DIN1 Slot ID 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DIN2 Slot ID 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DIN3 Slot ID 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
There are 16 channels mapping configuration, each wire selects four slots for RX. The following figure shows
the 16-channel mapping configuration.
LRCK
BCLK
DIN0 16 slot 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DIN1 16 slot 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DIN2 16 slot 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DIN3 16 slot 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
RX Mapping 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
8.1.3.5 ASRC
The ASRC module supports sampling rate conversion between the up-sampling and down-sampling. The ASRC
also supports sampling rate conversion between dual-channel audio data, and the size of the sampling data is
up to 24 bits.
Supports sampling rate conversion between the up-sampling and down-sampling to implement the
sampling rate conversion for stereo data
Sampling rate for both the input and output range is from 8 kHz to 192 kHz and can be decimal
The ASRC input is connected to I2S RX_FIFO_WDATA [31:8], and the input data is 24-bit MSB big-endian.
For the input data that is less than 24 bits, use zeros to pad out the values at the low bits instead of high
bits
The ASRC needs some time to calculate the result. The output outsamplea/b will keep 0 during the
calculation, and then change to the valid value when the result comes out
Calculate the ASRC up-sampling and down-sampling latency according to the following formulas.
ASRC Timing
The MCLK samples the input clock CLKIN to generate pulse signals.
The following figure shows the timing requirements for the inputs.
Tsu=0 Th=5*MCLK
Valid Data
Min= 5*MCLK
Min= 5*MCLK
The following figure shows the timing requirements for the outputs.
Min= 5*MCLK
Min= 5*MCLK
3*MCLK 100*MCLK
Valid Data
The following table provides the proper values of MCLK in MHz with different Fsin and Fsout in kHz.
Table 8-4 Proper MCLK Values with Different Fsin and Fsout
Fsout
32 44.1 48 88.2 96 144 192
Fsin
32 45 60 65 120 130 195 260
44.1 55 60 65 120 130 195 260
48 60 65 65 120 130 195 260
88.2 105 105 110 120 130 195 260
96 110 115 115 125 130 195 260
144 160 165 165 175 180 195 260
192 210 215 215 225 230 245 260
Note: The units for Fsin and Fsout are kHz and MCLK is MHz.
The software operation of the I2S/PCM is divided into five steps: system setup, I2S/PCM initialization, the
channel setup, DMA setup, and Enable/Disable module.
System Setup
Pin Multiplex
Globe/TX/RX Disable
I2S/PCM Initialization
PLL_AUDIO Frequence and Enable
Channel Setup
Clear TXFIFO/RXFIFO
CLK Reset and Gating
DMA Setup
The clock source for the I2S/PCM should be followed. Firstly, disable the PLL_AUDIO through PLL_AUDIOx
Control Register[PLL_ENABLE] in the CCU. Secondly, set up the frequency of the PLL_AUDIO in the
PLL_AUDIOx Control Register. After that, enable the I2S/PCM gating through the I2S/PCMx_CLK_REG
when you checkout that the PLL_AUDIOx Control Register[LOCK] becomes to 1. At last, reset and enable
the I2S/PCM bus gating by setting I2S/PCM_BGR_REG.
After the system setup, the register of I2S/PCM can be setup. Firstly, initialize the I2S/PCM. You should
close the Globe Enable bit (I2S/PCM_CTL[0]), Transmitter Block Enable bit (I2S/PCM_CTL[2]), and Receiver
Block Enable bit (I2S/PCM_CTL[1]) by writing 0. After that, clear the TX/RX FIFO by writing 0 to the
bit[25:24] of I2S/PCM_FCTL. At last, you can clear the TX FIFO and RX FIFO counter by writing 0 to
I2S/PCM_TXCNT and I2S/PCM_RXCNT.
First, you can set up the I2S/PCM of master and slave. The configuration can be referred to the protocol
of I2S/PCM. Then, you can set up the translation mode, the sample resolution, the wide of the slot, the
channel slot number, and the trigger level, and so on. The setup of the register can be found in the
specification.
The I2S/PCM supports two methods to transfer the data. The most common way is DMA, the setup of
DMA can be found in the “DMA”. In this module, you just enable the DRQ.
To enable the function, you can enable TX/RX by writing I2S/PCM_CTL[TXEN]/I2S/PCM_CTL[RXEN]. After
that, enable I2S/PCM by writing 1 to I2S/PCM_CTL[Globe Enable]. Write 0 to the Globe Enable bit to
disable I2S/PCM.
The following example shows a typical application of ASRC: the input data is 24-bit valid, and the output data
is a 32-bit data whose highest 24 bits are valid output and the lowest eight bits are padded out with zeros.
To implement the application, configure the sample resolution and slot width as 32 bits. Follow the steps below:
Step 1 For the input register: 0x04 [6:4] sample_res = 3`h7, 0x04 [2:0] slot_width = 3`h7.
The format of the input data: 32’hXXXXXXXX, where, bit[31] is the MSB and X is the valid data bit.
Step 2 For the output register: 0x04 [6:4] sample_res = 3`h7, 0x04 [2:0] slot_width = 3`h7
The format of the output data: 32’hXXXXXX00, where, bit[31] is the MSB, X is the valid data bit, and
bit[7:0] are the padded zeros.
Converting a 48 kHz sampling rate to 16 kHz is the most common scenario in actual applications. Follow the
steps below to convert the sampling rate from 48 kHz to 16 kHz for the 32-bit data.
b) It is suggested that you configure the ASRC MCLK as an equal-duty-cycle signal. You can specify an
odd number for bit[21:16] (PLL_POST_DIV_P) of PLL_AUDIO0_CTRL_REG to get an equal-duty-cycle
output clock of PLL_AUDIO0.
a) Configure bit[7:4] (BCLKDIV) of I2S/PCM_CLKD as 4`h9, that is, the frequency of BCLK will be 98.286
MHz/32 = 3.072 MHz.
b) Configure bit[17:8] (LRCK_PERIOD) of I2S/PCM_FMT0 as 10`h1F. That is, the LRCK_PERIOD width is
configured as 32 BLCKs and can generate the ASRC CLKIN with a 48 kHz sampling rate.
3.072MHz
( = 48kHz )
32* 2
c) Configure bit[6:4] (Sample Resolution bits) of I2S/PCM_FMT0 as 3`h7 to specify the sample
resolution as 32-bit.
d) Configure bit[2:0] (Slot Width bits) of I2S/PCM_FMT0 as 3`h7 to specify the slot width as 32-bit.
a) Configure bit[16] (clock gate) of MCLKCFG as 1`h1 to open the clock gating.
b) Configure bit[3:0] (division factor) of MCLKCFG as 1`h1 to specify the division factor as 1.
c) Configure bit[20] (clock gate ) of FSOUTCFG as 1`h1 to open the clock gating.
d) Configure bit[19:16] (clock select) of FSOUTCFG as 4`h0 to select I2S0_ASRC_CLK as the clock source.
e) Configure bit[7:4] (the first division factor) of FSOUTCFG as 16`h13 to configure the first division factor
as 128.
f) Configure bit[3:0] (the second division factor) of FSOUTCFG as 16`h10 to configure the second division
factor as 48.
To configure the ASRC ratio manually, configure bit[31] (Manual Configuration of ASRC Ratio Enable)
of ASRCMANCFG as 1`h1 to enable the manual configuration of ASRC ratio. Configure bit[25:0] of
ASRCMANCFG as 26`h155555 to specify the ratio value as 0x155555. The calculation formula for the
ratio value: Dec2Hex (Fsout/Fsin)*222). In this example, Fsout/Fsin = 16 kHz/48 kHz =1/3, then the
ratio is 0x155555.
To configure the ASRC ratio automatically, configure bit[31] (Manual Configuration of ASRC Ratio
Enable) of ASRCMANCFG as 1`h0 to enable the automatic configuration of ASRC ratio. Then the
system will automatically calculate the ratio value based on the MCLK, Fsout, and Fsin.
8.1.6.8 0x001C I2S/PCM DMA & Interrupt Control Register (Default Value: 0x0000_0000)
8.1.6.14 0x0034 I2S/PCM TX0 Channel Select Register (Default Value: 0x0000_0000)
8.1.6.15 0x0038 I2S/PCM TX1 Channel Select Register (Default Value: 0x0000_0000)
8.1.6.16 0x003C I2S/PCM TX2 Channel Select Register (Default Value: 0x0000_0000)
8.1.6.17 0x0040 I2S/PCM TX3 Channel Select Register (Default Value: 0x0000_0000)
8.1.6.18 0x0044 I2S/PCM TX0 Channel Mapping0 Register 0 (Default Value: 0x0000_0000)
8.1.6.19 0x0048 I2S/PCM TX0 Channel Mapping1 Register 1 (Default Value: 0x0000_0000)
8.1.6.20 0x004C I2S/PCM TX1 Channel Mapping0 Register 0 (Default Value: 0x0000_0000)
8.1.6.21 0x0050 I2S/PCM TX1 Channel Mapping1 Register 1 (Default Value: 0x0000_0000)
8.1.6.22 0x0054 I2S/PCM TX2 Channel Mapping0 Register 0 (Default Value: 0x0000_0000)
8.1.6.23 0x0058 I2S/PCM TX2 Channel Mapping1 Register 1 (Default Value: 0x0000_0000)
8.1.6.24 0x005C I2S/PCM TX3 Channel Mapping0 Register 0 (Default Value: 0x0000_0000)
8.1.6.25 0x0060 I2S/PCM TX3 Channel Mapping1 Register 1 (Default Value: 0x0000_0000)
8.1.6.31 0x0080 I2S/PCM ASRC MCLK Configuration Register (Default Value: 0x0000_0000)
8.1.6.32 0x0084 I2S/PCM ASRC OUT Sample Configuration Register (Default Value: 0x0000_0000)
00: I2S0_ASRC_CLK
19:16 R/W 0x0 01: ACLK
10: ACLKM
11: BCLK
Others: Reserved
15:8 / / /
FSOUT_CLK_FREQ_DIV_COE1
8.1.6.33 0x0088 I2S/PCM IN Sample Pulse Extend Configuration Register (Default Value: 0x0000_0000)
8.1.6.35 0x0090 I2S/PCM ASRC Manual Configuration Register (Default Value: 0x0000_0000)
8.1.6.36 0x0094 I2S/PCM ASRC Ratio State Register (Default Value: 0x0040_0000)
ADAPT_COMPUT_LOCK
ADAPT_COMPUT_VALUE
25:0 R 0x400000
Adaptive Ratio Computational Value
8.1.6.37 0x0098 I2S/PCM ASRC FIFO State Register (Default Value: 0x0000_0000)
ASRC_RX_FIFO_FULL_LEVAL
8.1.6.38 0x009C I2S/PCM MBIST Test Configuration Register (Default Value: 0x0000_0000)
ASRC_RAM_BIST_EN
8 R/W 0x0 ASRC RAM BIST Enable
Enable the RAM BIST.
7:1 / / /
ASRC_ROM_BIST_EN
0 R/W 0x0 ASRC ROM BIST Enable
8.1.6.39 0x00A0 I2S/PCM ASRC MBIST Test State Register (Default Value: 0x0000_0002)
0: ROM idle
15:8 / / /
RAM_BIST_ERR_STATUS
0: No effect
RAM_BIST_ERROR_PATTERN.
6:4 R 0x0
RAM BIST error pattern
RAM_BIST_ERROR_CYCLE
3:2 R 0x0
RAM BIST error cycle
RAM_STOP_STATUS
0: Running
RAM_BUSY_STATUS
0: RAM idle
8.2 DMIC
8.2.1 Overview
The DMIC controller supports one 8-channel digital microphone interface and can output 128 fs or 64 fs (fs =
ADC sample rate).
Supports up to 8 channels
PLL_AUDIO
Clock
DMIC_CLK
Divider
APB RXFIFO
I/F
Receiver DMIC_DATA[3:0]
The following table describes the clock source for DMIC. For clock setting, configurations, and gating
information, refer to section 3.3 “CCU”.
The software operation of the DMIC is divided into five steps: system setup, DMIC initialization, channel setup,
DMA setup, and Enable/Disable module.
The following figure shows the flow chart of the whole operation, the system setup, and the DMIC initialization.
System Setup
Pin Multiplex
Globe Disable
DMIC Initialization
PLL_AUDIO Frequence and Enable
Channel Setup
Flush RXFIFO
CLK Reset and Gating
DMA Setup
The first step in the system setup is properly programming the GPIO because the DMIC port is a multiplex
pin. For functions of the multiplex pins, refer to the pin multiplex specification.
Perform the following steps for the clock source. Firstly, disable the PLL_AUDIO through PLL_AUDIOx
Control Register[PLL_ENABLE]. Secondly, set up the frequency of the PLL_AUDIO in PLL_AUDIOx Control
Register. Then enable PLL_AUDIO. After that, enable the DMIC gating through DMIC_CLK_REG when you
checkout that the LOCK bit of PLL_AUDIOx Control Register becomes 1. At last, reset and enable the DMIC
bus gating by DMIC_BGR_REG.
After the system setup, the register of DMIC can be setup. Firstly, initialize the DMIC. You should close the
globe enable bit (DMIC_EN[8]), data channel enable bit (DMIC_EN[7:0]) by writing 0 to it. After that, flush
the RXFIFO by writing 1 to DMIC_RXFIFO_CTR[31]. At last, you can clear the Data/RXFIFO counter by
writing 1 to DMIC_RXFIFO_STA, DMIC_CNT.
You can set up the sample rate, the sample resolution, the over-sample rate, the channel number, the
RXFIFO output mode, the RXFIFO trigger level, and so on. The setup of the register can be found in the
specification.
The DMIC supports two methods to transfer the data. The most common way is DMA, the setup of DMA
can be found in section 3.9 “DMAC”. In this module, you just enable the DRQ.
To enable the function, you can enable the data channel enable bit (DMIC_EN[7:0]) by writing 1 to it. After
that, enable DMIC by writing 1 to the Globe Enable bit (DMIC_EN[8]). Write 0 to DMIC_EN[8] to disable
DMIC.
8.2.5.12 0x0030 DATA0 and DATA1 Volume Control Register (Default Value: 0xA0A0_A0A0)
8.2.5.13 0x0034 DATA2 and DATA3 Volume Control Register (Default Value: 0xA0A0_A0A0)
8.2.5.14 0x0038 High Pass Filter Enable Control Register (Default Value: 0x0000_0000)
8.2.5.15 0x003C High Pass Filter Coefficient Register (Default Value: 0x00FF_AA45)
8.2.5.16 0x0040 High Pass Filter Gain Register (Default Value: 0x00FF_D522)
8.3 OWA
8.3.1 Overview
The One Wire Audio (OWA) provides a serial bus interface for audio data. This interface is widely used for
consumer audio.
- IEC-61937 uses the IEC-60958 series for the conveying of non-linear PCM bit streams, each sub-
frame transmits 16-bit
- One 128×24bits TXFIFO and one 64×24bits RXFIFO for audio data transfer
- The clock of TX function includes a series of 24.576 MHz and 22.579 MHz frequency
- The clock of RX function includes a series of 24.576*8 MHz frequency (RX function clock 24.576*8
MHz supports CDR of sample rate from 8 kHz to 192 kHz)
PLL_AUDIO
Clock Divider
RXFIFO RXDET
Channel status
& user data
Transmitter OWA_OUT
buffers
TXFIFO
Clock Divider
DMA & INT
PLL_AUDIO
Sub-block Description
Registers Analyze the configuration parameter, DMA requests, and IRQ feedbacks.
Receiver Parses the frame header and receives the data.
Transmitter Sends the data
FSM Finite state machine
Clock Divider Clock divider circuit
The OWA is a Biphase-Mark Encoding Digital Audio Transfer protocol. In this protocol, the CLK signal and data
signal are transferred in the same line. The following figure describes the external signals of OWA. OWA-OUT
is the output pin for the output CLK and DATA, and OWA-IN is the input pin for the input CLK and DATA.
The OWA has separate clock for OWA_TX and OWA_RX. The following tables describe the clock sources for
OWA_TX and OWA_RX. For clock setting, configurations and gating information, refer to section 3.3 “CCU”.
In the OWA format, the digital signal is coded using the biphase-mark code (BMC). The clock, frame, and data
are embedded in only one signal—the data pin. In the BMC system, each data bit is encoded into two logical
states (00, 01, 10, or 11) at the pin. The following figure and table show how data is encoded to the BMC format.
The frequency of the clock is twice the data bit rate, as shown in the following figure. Also, the clock is always
programmed to 128 x fs, where fs is the sample rate. The device receiving in the OWA format can recover the
clock and frame information from the BMC signal.
Clock
128 × FS
Data
1 0 1 1 0 0 1 0 1 1 0
BMC
1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 0 1 0 1 0 1 1
The OWA supports digital audio data transfer and receive. It also supports full-duplex synchronous work mode.
The software can set the work mode by the OWA Control Register.
Every audio sample transmitted in a sub-frame consists of 32-bit, numbered from 0 to 31. The following figure
shows a sub-frame.
0 3 4 7 8 27 28 31
L M
Sync
Aux S Audio sample word S V U C P
preamble
B B
Validity flag
User data
Channel status
Parity bit
Bits 0-3 carry one of the four permitted preambles to signify the type of audio sample in the current sub-frame.
The preamble is not encoded in BMC format, and therefore the preamble code can contain more than two
consecutive 0 or 1 logical states in a row.
Bits 4-27 carry the audio sample word in linear 2s-complement representation. The most-significant bit (MSB)
is carried by bit 27. When a 24-bit coding range is used, the least-significant bit (LSB) is in bit 4. When a 20-bit
coding range is used, bit[8:27] carry the audio sample word with the LSB in bit 8. Bit[4:7] may be used for other
applications and are designated auxiliary sample bits.
If the source provides fewer bits than the interface allows (either 20 or 24), the unused LSBs are set to logical
0. For a nonlinear PCM audio application or a data application, the main data field may carry any other
information.
Bit 28 carries the validity bit (V) associated with the main data field in the sub-frame.
Bit 29 carries the user data channel (U) associated with the main data field in the sub-frame.
Bit 30 carries the channel status information (C) associated with the main data field in the sub-frame. The
channel status indicates if the data in the sub-frame is a digital audio or some other type of data.
Bit 31 carries a parity bit (P) such that bit 4-31 carry an even number of 1s and an even number of 0s (even
parity). As shown in the following table, the preambles (bit 0-3) are also defined with even parity.
Sub-frame Sub-frame
Block
IEC 61937 applies to the digital audio interface by using the IEC 60958 series for the conveying of non-linear
PCM encoded audio bitstreams. The non-linear PCM encoded audio bitstream is transferred by using the basic
16-bit data area of the IEC 60958 subframes, i.e. in time-slots 12 to 27. Because the non-linear PCM encoded
audio bitstream to be transported is at a lower data rate than that supported by the IEC 60958 interface, the
audio bitstream is broken into a sequence of discrete data-bursts, and stuffing between the data-bursts is
necessary .
The method of placing the data into the IEC 60958 bitstream is to format the data to be transmitted into data-
bursts and to send each data-burst in a continuous sequence of IEC 60958 frames.
Each data-burst contains a burst-preamble consisting of four 16-bit words (Pa, Pb, Pc and Pd) followed by the
burst-payload which contains data of an encoded audio frame.
(1) Burst-preamble
The burst-preamble consists of four mandatory fields. Pa and Pb represent a synchronization word. Pc gives
information about the type of data, and some information/control for the receiver. Pd gives the length of the
burst-payload, and is limited to 65535 bits in the case of Pd represent bits length, or is limited to 65535 bytes
in the case of Pd represent bytes length.
The four preamble words are contained in two sequential IEC 60958 frames. The frame beginning the data-
burst contains preamble word Pa in subframe 1, and Pb in subframe 2. The next frame contains Pc in subframe
1 and Pd in subframe 2. When placed into an IEC 60958 subframe, the MSB of a 16-bit burst-preamble word is
placed into time-slot 27 and the LSB is placed into time-slot 12.
(2) Burst-information
The 16-bit burst-information contains information about the data which will be found in the data-burst.
The 7-bit data-type is defined in bits 0-6 of the burst-preamble Pc, the bit 6 is the MSB. This data-type field
indicates the format of the burst-payload, which will be conveyed in the data-burst. Typical properties of a
data-type are the reference point and repetition period of the burst, which is the number of sampling periods
of the audio between the reference point of the current data-burst and the reference point of the next data-
burst. The reference point is inherently defined for each data-type.
The error-flag bit is available to indicate if the contents of the data-burst contain data errors.If a data-burst is
thought to be error-free, or if the data source does not know if the data contains errors, then the value of this
bit is set to a ‘0’. If the data source does know that a particular data-burst contains some errors this bit may be
set to a ’1’. The usage of this bit by receiver is optional.
The meaning of the 5-bit data-type-dependent info depends on the value of the data-type.
The 3-bit bitstream-number indicates to which bitstream the data-burst belongs. Eight codes (0-7) are available
so that up to eight independent bitstreams may be multiplexed in one bitstream in a time multiplex. Each
independent bitstream shall use a unique bit-streamnumber.
(3) Length-code
The length-code indicates the number of bits or bytes according to data-type within the databurst, from 0 to
65535. The size of the Pa, Pb, Pc and Pd is not counted in the value of the length-code. In other words, the
length-code indicates the number of bits of the burst-payload in bits, plus the conditional length of Pe and Pf,
or the number of bytes of the burst-payload in bytes, plus the conditional length of Pe and Pf if exists.
The sampling rate is calculated according to the data pulse back-stepping method. In the first phase lock of the
CDR, find 1 Frame period, count by using the high-speed sampling clock, and read the counting value of the
pulse, then the sampling rate can be calculated.
Table 8-14 The Corresponding Relation between Different System Clock and Sample Ratio
The software operation of the OWA is divided into five steps: system setup, OWA initialization, channel setup,
DMA setup and enable/disable module. The following sections describe these five steps.
System Setup
Pin Multiplex
Globe/TX/RX Disable
OWA Initialization
PLL_AUDIO Frequence and Enable
Channel Setup
Clear TXFIFO/RXFIFO
CLK Reset and Gating
DMA Setup
The first step in the OWA initialization is properly programming the GPIO because the OWA port is a multiplex
pin. You can find the function in section 9.7 “GPIO”.
The clock source for the OWA should be followed. Firstly, reset the audio PLL in PLL_AUDIOx Control Register.
Secondly, set up the frequency of the Audio PLL in the PLL_AUDIOx Control Register. After that, enable the
OWA gating. Lastly, enable the OWA bus gating.
After the system setup, the register of OWA can be set up. Firstly, reset the OWA by writing 1 to OWA_CTL[0]
and clear the TX/RX FIFO by writing 1 to OWA_FCTL[17:16]. After that, enable the globe enable bit by writing
1 to OWA_CTL[1] and clear the interrupt and TX/RX counter by setting OWA_ISTA and
OWA_TX_CNT/OWA_RX_CNT.
You can set up the audio type, clock divider ratio, the sample format, and the trigger level, and so on. The setup
of the register can be found in the specification.
The OWA supports two methods to transfer the data. The most common way is DMA, the configuration of
DMA can be found in section 3.9 “DMAC”. In this module, you just enable the DRQ in OWA_INT[7].
To enable the function, you can enable TX/RX by writing OWA_TX_CFIG[31]/OWA_RX_CFIG[0]. After that,
enable OWA by writing 1 to OWA_CTL[1]. Writing 0 to OWA_CTL[1] to disable process.
31:0 R/W 0x0 When one sample is put into TXFIFO by DMA or by host IO, the
TX sample counter register increases by one. The TX sample
counter register can be set to any initial value at any time. After
updated by the initial value, the counter register should count
on the base of this initial value.
31:0 R/W 0x0 When one sample is written by Codec, the RX sample counter
register increases by one. The RX counter register can be set to
any initial value at any time. After being updated by the initial
value, the counter register should count on the base of this
value.
8.3.5.17 0x0044 OWA Expand Interrupt Status Register (Default Value: 0x0000_0000)
8.4.1 Overview
The Audio Codec is high-performance audio encoder and decoder module which supports DAC/ADC, dynamic
range controller (DRC) and dynamic voltage controller (DVC) functions.
- One differential microphone input: MICIN3P/3N, or one single-end microphone input: MICIN3P
Supports Dynamic Range Controller (DRC) adjusting the ADC recording and DAC playback
One 128x20-bit FIFO for DAC data transmit, one 128x20-bit FIFO for ADC data receive
0.9 V Reference
VRA1
0.9 V Voltage
VRA2 APB BUS
AGND
1.8 V
AVCC
HP_DET HP_DET
Register
MIC_DET MIC_DET
RXFIFO TXFIFO
1.8 V
HPVCC
FMINL
Mixer ADC1
LINEINL
DACL HPOUTL
ADC DAC
Volume Volume HPOUTR
FMINR DAP Headphone HPOUTFB
Mixer ADC2 High High
LINEINR
Filter Filter DACR
MICIN3P
PGA ADC3
MICIN3N
The following figure describes the clock source of Audio Codec. For clock setting, configuration, and gating
information, refer to section 3.3 “CCU”.
APBCLK
Digital Control Register
ADCCLKSEL HPF&DRC
PLL_AUDIO0
24.576 MHz ADCCLK
ADC_DIGITAL
DACCLK
PLL_AUDIO1 DAC_DIGITAL
24.576 MHz/22.5792 MHz
DACCLKSEL
CLK32K
CLK32K_RTC VRA1_SPEEUP
Digital Part
CK_ADC
ADC_ANALOG
CK_DAC
DAC_ANALOG
Analog Part
The clock source for the digital part is the PLL_AUDIO0 and PLL_AUDIO1. For the ADC clock, configure
AUDIO_CODEC_ADC_CLK_REG[25:24] to select the clock source. For the DAC clock, configure
AUDIO_CODEC_DAC_CLK_REG[25:24] to select the clock source. The PK-PK jitter of PLL_AUDIO0 and
PLL_AUDIO1 should be less than 200 ps.
The clock source for the analog part is the CK_ADC and CK_DAC, both of which are divided from the digital part.
The following figure shows the reset system of the audio codec digital part.
HPF&DRC
The SYS_RST comes from the VDD-SYS domain and is produced by the RTC domain. Each domain has the de-
bounce to confirm the reset system is strong. For the codec register part, MIX can be reset by the SYS_RST
when being powered on or the system soft is writing the reset control logic. The other parts can be reset by
the soft configuration through writing the register.
The following figure shows the reset system of the audio codec analog part.
AVCC ANALOG
POWER ON LS RC
PART
When AVCC is powered on, it sends the AVCC_POR signal. The AVCC_POR signal passes the level shift and RC
filter part to the ADDA logic core.
FMINL
ADC1 Reg000[31]
LINEINL Reg310[15]
Reg300[31] Reg324[15]
Reg030[28]
Reg050[00] DACL G HPOUTL
F F
FMINR D D
ADC2 I APB APB I
A A
LINEINR F F Reg000[31]
P P Reg310[14]
Reg308[31] O O
Reg030[28] Reg324[15]
Reg050[01] DACR G HPOUTR
Reg308[30]
MICIN3P +
-G
ADC3
MICIN3N
Reg308[31]
Reg030[28]
Reg050[02]
The three ADCs are used for recording stereo sound and a reference signal. The sample rates of the three ADCs
are independent of the DAC sample rate. The digital ADC part can be enabled or disabled by the bit[28] of the
AC_ADC_FIFOC register.
The stereo DAC sample rate can be configured by setting the register. To save power, the analog DACL can be
enabled or disabled by setting the bit[15] of the DAC_REG register, and the analog DACR can be enabled or
disabled by setting the bit[14] of the DAC_REG register. The digital DAC part can be enabled or disabled by the
bit[31] of the AC_DAC_DPC register.
MICIN3P/N
LINEINL/R
FMINL/R
LINEINL, FMINL provide differential input that can be mixed into the ADC1 record mixer. LINEINR, FMINR
provide differential input that can be mixed into the ADC2 record mixer. MICIN3P/N provides differential input.
The MICIN is a high impedance, low capacitance input suitable for connecting to various differential
microphones of different dynamics and sensitivity. The gain for each pre-amplifier can be set independently.
HPOUTL/R
The headphone PA is powered up or down by HP_REG[bit15] (HPPA_EN). HPOUTL/R can drive a 16R or 32R
headphone load without DC capacitors by using Charge Pump to generate the negative rails. HP-FB is the
ground loop noise rejection feedback.
HBIAS
Headphone
Driver HPOUTL
HPOUTR
HP-FB
8.4.3.9 Interrupts
The Audio Codec has two interrupts. The following figure describes the Audio Codec interrupt system.
ADC_IRQ_EN
ADC_IRQ_STATUS
ADC_IRQ
ADC_OVERRUN_IRQ_EN
ADC_OVERRUN_IRQ_STATUS
IRQ
DAC_IRQ_EN
DAC_IRQ_STATUS
DAC_OVERRUN_IRQ_EN DAC_IRQ
DAC_OVERRUN_IRQ_STATUS
DAC_UNDERRUN_IRQ_EN
DAC_UNDERRUN_IRQ_STATUS
The DAP module is used to remove the DC offset and automatically adjusts the volume to a flatten volume
level. It mainly consists of two HPF and one DRC.
M
U L
HPF X
DRC
Alpha Filter
M M
Compression Smooth U
U
X control Filter X
Alpha Filter
M
U R
HPF X
HPF Function
The DAP has individual channel high pass filter (HPF, -3 dB cutoff < 1 Hz) that can be enabled and disabled. The
filter cutoff frequency is less than 1 Hz that can be removed DC offset from ADC recording. The HPF can also
be bypassed.
DRC Function
The DRC scheme has three thresholds, three offsets, and four slopes (all programmable). There is one ganged
DRC for the left and right channels. The following figure shows the diagram of DRC input/output.
x(n) g(n)
Energy Compression Smooth
Filter control Filter
-100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0
(Outpu t dB)
-10
-20
OPL
Kl -30
OPC Kc
-40
-50
Kn
-60
OPE
-70
-80
Ke
-90
-100
NT ET CT LT (Inpu t dB)
Professional-quality dynamic range compression automatically adjusts the volume to flatten volume level.
One DRC for left/right and one DRC for the subwoofer.
Each DRC has an adjustable threshold, offset, and compression levels, programmable energy, attack, and decay
time constants.
Transparent compression: Compressors can attack fast enough to avoid apparent clipping before engaging,
and decay times can be set slow enough to avoid pumping.
Number format
The Number format is N.M which means there are N bits to the left of the decimal point including the sign
bit and M bits to the right of the decimal point. For example, Numbers formatted 9.23 means that there
are 9 bits at the left of the decimal point and 23 bits at the right decimal point.
Energy Filter
The Energy Filter is to estimate the RMS value of the audio data stream into DRC and has two parameters,
which determine the time window over which RMS to be made. The parameter is computed by
1 e2.2Ts / ta .
For the Compression Control, there are ten parameters (ET, CT, LT, Ke, Kn, Kc, Kl, OPL, OPC, and OPE), which
are all programmable, and the computation will be explained as follows.
The threshold is the value that determines the signal to be compressed or not. When the RMS of the signal
is larger than the threshold, the signal will be compressed. The value of threshold input to the coefficient
TdB
register is computed by Tin .
6.0206
Where, TdB must less than zero, the positive value is illegal.
For example, it is desired to set CT = -40 dB, then the Tin require to set CT to -40 dB is CTin = - (-40
dB)/6.0206 = 6.644, CTin is entered as a 32-bit number in 8.24 format.
Therefore, CTin = 6.644 = 0000 0110.1010 0100 1101 0011 1100 0000 = 0x06A4 D3C0 in 8.24 format.
The K is the slope within the compression region. For example, an n: 1 compression means that an output
1
increase of 1 dB is for n dB RMS input. The k input to the coefficient ram is computed by K
n
Where, n is from 1 to 50, and must be an integer.
For example, it is desired to set to 2:1, then the Kc requires to set to 2:1, is Kc = 1/2 = 0.5, Kc is entered as
a 32-bit number in 8.24 format.
Therefore, Kc = 0.5 = 0000 0000.1000 0000 0000 0000 0000 0000 = 0x0080 0000 in 8.24 format.
The Gain Smooth Filter is to smooth the gain and control the ratio of gain increase and decrease. The
decay time and attack are shown in Figure 8-36. The structure of the Gain Smooth filter is also the Alpha
filter, so the rise time computation is the same as the Energy filter which is 1 e2.2Ts / ta .
Input
Signal
Output
Signal
Target Level
Gain
In recording mode, the analog audio signals are recorded from the microphones at the specified sample rate,
processed by the ADC, and then transferred to the DRAM via the DMA.
Step 1 Codec initialization: configure AUDIO_CODEC_BGR_REG to open the audio codec bus clock gating
and de-assert bus reset; configure AUDIO_CODEC_ADC_CLK_REG and PLL_AUDIO0_CTRL_REG to
configure PLL_Audio0 frequency and enable PLL_Audio0. For details, refer to section 3.3 “CCU”.
Step 2 Configure the sample rate and data transfer format, then open the ADC.
In playback mode, the audio data are transferred from the DRAM via DMA, processed by the DAC, and finally
output via the analog interface.
Step 1 Codec initialization: configure AUDIO_CODEC_BGR_REG to open the audio codec bus clock gating
and de-assert bus reset; configure AUDIO_CODEC_DAC_CLK_REG and PLL_AUDIO1_CTRL_REG to
configure PLL_Audio1 frequency and enable PLL_Audio1. For details, refer to section 3.3 “CCU”.
Step 2 Configure the sample rate and data transfer format, then open the DAC.
8.4.6.1 0x0000 DAC Digital Part Control Register (Default Value: 0x0000_0000)
ADC_CHANNEL_EN
Bit 3: ADC4 enabled
2:0 R/W 0x0 Bit 2: ADC3 enabled
Bit 1: ADC2 enabled
Bit 0: ADC1 enabled
8.4.6.15 0x0054 VRA1 Speedup Down Control Register (Default Value: 0x0000_0000)
8.4.6.18 0x0100 DAC DRC High HPF Coef Register (Default Value: 0x0000_00FF)
8.4.6.19 0x0104 DAC DRC Low HPF Coef Register (Default Value: 0x0000_FAC1)
8.4.6.21 0x010C DAC DRC Left Peak Filter High Attack Time Coef Register (Default Value: 0x0000_000B)
8.4.6.22 0x0110 DAC DRC Left Peak Filter Low Attack Time Coef Register (Default Value: 0x0000_77BF)
8.4.6.23 0x0114 DAC DRC Right Peak Filter High Attack Time Coef Register (Default Value: 0x0000_000B)
8.4.6.24 0x0118 DAC DRC Left Peak Filter Low Attack Time Coef Register (Default Value: 0x0000_77BF)
8.4.6.25 0x011C DAC DRC Left Peak Filter High Release Time Coef Register (Default Value: 0x0000_00FF)
8.4.6.26 0x0120 DAC DRC Left Peak Filter Low Release Time Coef Register (Default Value: 0x0000_E1F8)
8.4.6.27 0x0124 DAC DRC Right Peak Filter High Release Time Coef Register (Default Value: 0x0000_00FF)
8.4.6.28 0x0128 DAC DRC Right Peak filter Low Release Time Coef Register(Default Value: 0x0000_E1F8)
8.4.6.29 0x012C DAC DRC Left RMS Filter High Coef Register (Default Value: 0x0000_0001)
8.4.6.30 0x0130 DAC DRC Left RMS Filter Low Coef Register (Default Value: 0x0000_2BAF)
8.4.6.31 0x0134 DAC DRC Right RMS Filter High Coef Register (Default Value: 0x0000_0001)
8.4.6.32 0x0138 DAC DRC Right RMS Filter Low Coef Register (Default Value: 0x0000_2BAF)
8.4.6.33 0x013C DAC DRC Compressor Theshold High Setting Register (Default Value: 0x0000_06A4)
8.4.6.34 0x0140 DAC DRC Compressor Slope High Setting Register (Default Value: 0x0000_D3C0)
8.4.6.35 0x0144 DAC DRC Compressor Slope High Setting Register (Default Value: 0x0000_0080)
8.4.6.36 0x0148 DAC DRC Compressor Slope Low Setting Register (Default Value: 0x0000_0000)
8.4.6.37 0x014C DAC DRC Compressor High Output at Compressor Threshold Register (Default Value: 0x0000_F95B)
8.4.6.38 0x0150 DAC DRC Compressor Low Output at Compressor Threshold Register (Default Value: 0x0000_2C3F)
8.4.6.39 0x0154 DAC DRC Limiter Theshold High Setting Register (Default Value: 0x0000_01A9)
8.4.6.40 0x0158 DAC DRC Limiter Theshold Low Setting Register (Default Value: 0x0000_34F0)
8.4.6.41 0x015C DAC DRC Limiter Slope High Setting Register (Default Value: 0x0000_0005)
8.4.6.42 0x0160 DAC DRC Limiter Slope Low Setting Register (Default Value: 0x0000_1EB8)
8.4.6.43 0x0164 DAC DRC Limiter High Output at Limiter Threshold Register (Default Value: 0x0000_FBD8)
8.4.6.44 0x0168 DAC DRC Limiter Low Output at Limiter Threshold Register (Default Value: 0x0000_FBA7)
8.4.6.45 0x016C DAC DRC Expander Theshold High Setting Register (Default Value: 0x0000_0BA0)
8.4.6.46 0x0170 DAC DRC Expander Theshold Low Setting Register (Default Value: 0x0000_7291)
8.4.6.47 0x0174 DAC DRC Expander Slope High Setting Register (Default Value: 0x0000_0500)
8.4.6.48 0x0178 DAC DRC Expander Slope Low Setting Register (Default Value: 0x0000_0000)
8.4.6.49 0x017C DAC DRC Expander High Output at Expander Threshold Register (Default Value: 0x0000_F45F)
8.4.6.50 0x0180 DAC DRC Expander Low Output at Expander Threshold Register (Default Value: 0x0000_8D6E)
8.4.6.51 0x0184 DAC DRC Linear Slope High Setting Register (Default Value: 0x0000_0100)
8.4.6.52 0x0188 DAC DRC Linear Slope Low Setting Register (Default Value: 0x0000_0000)
8.4.6.53 0x018C DAC DRC Smooth Filter Gain High Attack Time Coef Register (Default Value: 0x0000_0002)
8.4.6.54 0x0190 DAC DRC Smooth Filter Gain Low Attack Time Coef Register (Default Value: 0x0000_5600)
8.4.6.55 0x0194 DAC DRC Smooth Filter Gain High Release Time Coef Register (Default Value: 0x0000_0000)
8.4.6.56 0x0198 DAC DRC Smooth Filter Gain Low Release Time Coef Register (Default Value: 0x0000_0F04)
8.4.6.57 0x019C DAC DRC MAX Gain High Setting Register (Default Value: 0x0000_FE56)
8.4.6.58 0x01A0 DAC DRC MAX Gain Low Setting Register (Default Value: 0x0000_CB0F)
8.4.6.59 0x01A4 DAC DRC MIN Gain High Setting Register (Default Value: 0x0000_F95B)
8.4.6.60 0x01A8 DAC DRC MIN Gain Low Setting Register (Default Value: 0x0000_2C3F)
8.4.6.61 0x01AC DAC DRC Expander Smooth Time High Coef Register (Default Value: 0x0000_0000)
8.4.6.62 0x01B0 DAC DRC Expander Smooth Time Low Coef Register (Default Value: 0x0000_640C)
8.4.6.63 0x01B8 DAC DRC HPF Gain High Coef Register (Default Value: 0x0000_0100)
8.4.6.64 0x01BC DAC DRC HPF Gain Low Coef Register (Default Value: 0x0000_0000)
8.4.6.65 0x0200 ADC DRC High HPF Coef Register (Default Value: 0x0000_00FF)
8.4.6.66 0x0204 ADC DRC Low HPF Coef Register (Default Value: 0x0000_FAC1)
8.4.6.68 0x020C ADC DRC Left Peak Filter High Attack Time Coef Register (Default Value: 0x0000_000B)
8.4.6.69 0x0210 ADC DRC Left Peak Filter Low Attack Time Coef Register (Default Value: 0x0000_77BF)
8.4.6.70 0x0214 ADC DRC Right Peak Filter High Attack Time Coef Register (Default Value: 0x0000_000B)
8.4.6.71 0x0218 ADC DRC Right Peak Filter Low Attack Time Coef Register (Default Value: 0x0000_77BF)
8.4.6.72 0x021C ADC DRC Left Peak Filter High Release Time Coef Register (Default Value: 0x0000_00FF)
8.4.6.73 0x0220 ADC DRC Left Peak Filter Low Release Time Coef Register (Default Value: 0x0000_E1F8)
8.4.6.74 0x0224 ADC DRC Right Peak Filter High Release Time Coef Register (Default Value: 0x0000_00FF)
8.4.6.75 0x0228 ADC DRC Right Peak Filter Low Release Time Coef Register (Default Value: 0x0000_E1F8)
8.4.6.76 0x022C ADC DRC Left RMS Filter High Coef Register (Default Value: 0x0000_0001)
8.4.6.77 0x0230 ADC DRC Left RMS Filter Low Coef Register (Default Value: 0x0000_2BAF)
8.4.6.78 0x0234 ADC DRC Right RMS Filter High Coef Register (Default Value: 0x0000_0001)
8.4.6.79 0x0238 ADC DRC Right RMS Filter Low Coef Register (Default Value: 0x0000_2BAF)
8.4.6.80 0x023C ADC DRC Compressor Theshold High Setting Register (Default Value: 0x0000_06A4)
8.4.6.81 0x0240 ADC DRC Compressor Slope High Setting Register (Default Value: 0x0000_D3C0)
8.4.6.82 0x0244 ADC DRC Compressor Slope High Setting Register (Default Value: 0x0000_0080)
8.4.6.83 0x0248 ADC DRC Compressor Slope Low Setting Register (Default Value: 0x0000_0000)
8.4.6.84 0x024C ADC DRC Compressor High Output at Compressor Threshold Register (Default Value: 0x0000_F95B)
8.4.6.85 0x0250 ADC DRC Compressor Low Output at Compressor Threshold Register (Default Value: 0x0000_2C3F)
8.4.6.86 0x0254 ADC DRC Limiter Theshold High Setting Register (Default Value: 0x0000_01A9)
8.4.6.87 0x0258 ADC DRC Limiter Theshold Low Setting Register (Default Value: 0x0000_34F0)
8.4.6.88 0x025C ADC DRC Limiter Slope High Setting Register (Default Value: 0x0000_0005)
8.4.6.89 0x0260 ADC DRC Limiter Slope Low Setting Register (Default Value: 0x0000_1EB8)
8.4.6.90 0x0264 ADC DRC Limiter High Output at Limiter Threshold Register (Default Value: 0x0000_FBD8)
8.4.6.91 0x0268 ADC DRC Limiter Low Output at Limiter Threshold Register (Default Value: 0x0000_FBA7)
8.4.6.92 0x026C ADC DRC Expander Theshold High Setting Register (Default Value: 0x0000_0BA0)
8.4.6.93 0x0270 ADC DRC Expander Theshold Low Setting Register (Default Value: 0x0000_7291)
8.4.6.94 0x0274 ADC DRC Expander Slope High Setting Register (Default Value: 0x0000_0500)
8.4.6.95 0x0278 ADC DRC Expander Slope Low Setting Register (Default Value: 0x0000_0000)
8.4.6.96 0x027C ADC DRC Expander High Output at Expander Threshold Register (Default Value: 0x0000_F45F)
8.4.6.97 0x0280 ADC DRC Expander Low Output at Expander Threshold Register (Default Value: 0x0000_8D6E)
8.4.6.98 0x0284 ADC DRC Linear Slope High Setting Register (Default Value: 0x0000_0100)
8.4.6.99 0x0288 ADC DRC Linear Slope Low Setting Register (Default Value: 0x0000_0000)
8.4.6.100 0x028C ADC DRC Smooth Filter Gain High Attack Time Coef Register (Default Value: 0x0000_0002)
8.4.6.101 0x0290 ADC DRC Smooth Filter Gain Low Attack Time Coef Register (Default Value: 0x0000_5600)
8.4.6.102 0x0294 ADC DRC Smooth Filter Gain High Release Time Coef Register (Default Value: 0x0000_0000)
8.4.6.103 0x0298 ADC DRC Smooth Filter Gain Low Release Time Coef Register (Default Value: 0x0000_0F04)
8.4.6.104 0x029C ADC DRC MAX Gain High Setting Register (Default Value: 0x0000_FE56)
8.4.6.105 0x02A0 ADC DRC MAX Gain Low Setting Register (Default Value: 0x0000_CB0F)
8.4.6.106 0x02A4 ADC DRC MIN Gain High Setting Register (Default Value: 0x0000_F95B)
8.4.6.107 0x02A8 ADC DRC MIN Gain Low Setting Register (Default Value: 0x0000_2C3F)
8.4.6.108 0x02AC ADC DAP Expander Smooth Time High Coef Register (Default Value: 0x0000_0000)
8.4.6.109 0x02B0 ADC DRC Expander Smooth Time Low Coef Register (Default Value: 0x0000_640C)
8.4.6.110 0x02B8 ADC DRC HPF Gain High Coef Register (Default Value: 0x0000_0100)
8.4.6.111 0x02BC ADC DRC HPF Gain Low Coef Register (Default Value: 0x0000_0000)
The register is not controlled by the clock and reset of Audio Codec, only controlled by the clock and reset of
system bus.
The register is not controlled by the clock and reset of Audio Codec, only controlled by the clock and reset of
system bus.
8.4.6.123 0x034C ADC Current Analog Control Register (Default Value: 0x0015_1515)
Contents
9 Interfaces ................................................................................................................................................................ 824
Figures
Figure 9-1 TWI Block Diagram ........................................................................................................................................... 825
Figure 9-2 Write Timing in 7-bit Standard Addressing Mode ........................................................................................... 827
Figure 9-3 Read Timing in 7-bit Standard Addressing Mode ............................................................................................ 827
Figure 9-11 Application Diagram for RTS/CTS Autoflow Control ...................................................................................... 853
Figure 9-17 UART Mode Baud and Error Rates ................................................................................................................. 855
Figure 9-19 RS485 Mode Baud and Error Rates ................................................................................................................ 856
Figure 9-39 DBI 3-Line Display Bus Serial Interface Writing Operation Format ............................................................... 936
Figure 9-40 DBI 3-Line Display Bus Serial Interface 8-bit Reading Operation Format ...................................................... 937
Figure 9-41 DBI 3-Line Display Bus Serial Interface 24-bit Reading Operation Format .................................................... 937
Figure 9-42 DBI 3-Line Display Bus Serial Interface 32-bit Reading Operation Format .................................................... 938
Figure 9-43 DBI 4-Line Display Bus Serial Interface Writing Operation Format ............................................................... 939
Figure 9-44 DBI 4-Line Display Bus Serial Interface 8-bit Reading Operation Format ...................................................... 939
Figure 9-45 DBI 4-Line Display Bus Serial Interface 24-bit Reading Operation Format .................................................... 940
Figure 9-46 DBI 4-Line Display Bus Serial Interface 32-bit Reading Operation Format .................................................... 940
Figure 9-47 RGB111 3-Line Interface Transmit Video Format .......................................................................................... 941
Figure 9-48 RGB444 3-Line Interface Transmit Video Format .......................................................................................... 941
Figure 9-49 RGB565 3-Line Interface Transmit Video Format .......................................................................................... 942
Figure 9-50 RGB666 3-Line Interface Transmit Video Format .......................................................................................... 942
Figure 9-51 RGB111 4-Line Interface Transmit Video Format .......................................................................................... 943
Figure 9-52 RGB444 4-Line Interface Transmit Video Format .......................................................................................... 943
Figure 9-53 RGB565 4-Line Interface Transmit Video Format .......................................................................................... 944
Figure 9-54 RGB666 4-Line Interface Transmit Video Format .......................................................................................... 944
Figure 9-55 RGB444 2 Data Lane Interface Transmit Video Format ................................................................................. 945
Figure 9-56 RGB565 2 Data Lane Interface Transmit Video Format ................................................................................. 946
Figure 9-57 RGB666 2 Data Lane Interface Transmit Video Format 0 .............................................................................. 947
Figure 9-58 RGB666 2 Data Lane Interface Transmit Video Format 1 (ilitek) ................................................................... 947
Figure 9-59 RGB666 2 Data Lane Interface Transmit Video Format 2 (New vision) ......................................................... 947
Figure 9-60 RGB888 2 Data Lane Interface Transmit Video Format ................................................................................. 948
Figure 9-64 USB2.0 DRD Controller and PHY Connection Diagram .................................................................................. 991
Figure 9-66 USB2.0 Host Controller and PHY Connection Diagram .................................................................................. 993
Figure 9-73 TPADC Single-Ended Mode for AUX ADC ..................................................................................................... 1150
Figure 9-75 Single Touch X-Coordinate Measurement for Touch Panel ......................................................................... 1151
Figure 9-76 Dual Touch Detection for Touch Panel ........................................................................................................ 1152
Figure 9-77 Touch Pressure Measurement for Touch Panel .......................................................................................... 1153
Figure 9-78 Pen Down Detection for Touch Panel .......................................................................................................... 1154
Figure 9-86 Phase of PWM0 High Level Active State ...................................................................................................... 1169
Figure 9-87 PWM0 Output Waveform in Pulse Mode and Cycle Mode ......................................................................... 1170
Figure 9-110 Logical ‘0’ and Logical ‘1’ of NEC Protocol ................................................................................................. 1256
Figure 9-118 Definitions of Logical “1” and Logical “0” .................................................................................................. 1268
Tables
Table 9-1 TWI Sub-blocks .................................................................................................................................................. 825
Table 9-10 SPI Old Sample Mode and Run Clock .............................................................................................................. 899
Table 9-16 SPI Old Sample Mode and Run Clock .............................................................................................................. 935
9 Interfaces
9.1 TWI
9.1.1 Overview
The Two Wire Interface (TWI) provides an interface between a CPU and any TWI-bus-compatible device that
connects via the TWI bus. The TWI is designed to be compatible with the standard I2C bus protocol. The
communication of the TWI is carried out by a byte-wise mode based on interrupt polled handshaking. Each
device on the TWI bus is recognized by a unique address and can operate as either transmitter or receiver, a
device connected to the TWI bus can be considered as master or slave when performing data transfers. Note
that a master device is a device that initiates a data transfer on the bus and generates the clock signals to
permit the transfer. During this transfer, any device addressed by this master is considered a slave.
Supports standard mode (up to 100 kbit/s) and fast mode (up to 400 kbit/s)
The TWI controller includes one TWI engine and one TWI driver. And the TWI driver supports packet
transmission and DMA mode when TWI works in master mode
INT TWI_TOP
RESET
DRV_EN TWI_ENGINE
APB
0
TWI_DRIVER
CFG_REG CCU
CFG_REG
1
dma_tx_req SEND_FIFO
TWI_SCK
dma_rx_req RECV_FIFO PE
TWI_SDA
Sub-block Description
RESET Module reset signal
INT Module output interrupt signal
CFG_REG Module configuration register in TWI
PE Packet encoding/decoding
CCU Module clock controller unit
The register address bytes and the written data bytes are buffered in
SEND_FIFO
SEND_FIFO
RECV_FIFO The read data bytes are buffered in RECV_FIFO
The controller includes TWI engine and TWI driver. Each time the TWI engine sends a START signal, a STOP
signal, or a BYTE data, or a corresponding ACK, the TWI engine will generate an interrupt, and wait for the CPU
to process and clear the interrupt before the next START, STOP, or BYTE, ACK transmission can be performed.
Therefore, when a device communication is completed, many interrupts will be generated, and the CPU needs
to wait for the previous interrupt before it can configure the next one. The TWI driver defines each
communication with the device as a packet transmission. The CPU can directly configure the slave address,
register address and data transmission for one or more package transmissions without waiting for interruption,
then start the TWI driver, and the TWI driver can control the TWI engine to complete a pre-configured
communication, and report an interrupt to the CPU after completion.
The TWI controller has 4 TWI modules called TWI0, TWI1, TWI2, and TWI3. The following table describes the
external signals of the TWI. The TWIn-SCK and TWIn-SDA are bidirectional I/O, when the TWI is configured as
a master device, the TWIn-SCK is an output pin; when the TWI is configurable as a slave device, the TWIn-SCK
is an input pin. When using TWI, the corresponding PADs are selected as TWI function via section 9.7 “GPIO”.
Each TWI controller has an input clock source. The following table describes the clock sources for TWI. After
selecting a proper clock, users must open the gating of TWI and release the corresponding reset bit.
For more details on the clock setting, configuration, and gating information, see section 3.3 “CCU”.
This section is the 7-bit/10-bit addressing mode of the entire TWI protocol to read and write device registers.
It can be achieved by directly using the TWI engine or using the TWI driver to control the TWI engine.
Figure 9-2 describes the write timing in 7-bit standard addressing mode.
Figure 9-3 describes the read timing in 7-bit standard address mode.
Sr:RE-START condition
Figure 9-4 describes the write timing in 10-bit extended address mode.
Figure 9-5 describes the read timing in 10-bit extended address mode.
Sr:RE-START condition
The TWI driver is only supported for master mode. When the TWI works in master mode, the TWI driver drives
the TWI engine for one or more packet transmission instead of the CPU host. Packet transmission is defined in
the following figures. The register address bytes and the written data bytes are buffered in SEND_FIFO, the
read data bytes are buffered in RECV_FIFO.
Slave_id+W Slave_id_x
Stop
Slave_id+W Slave_id_x
Stop
Slave_id+W Slave_id_x
Slave_id+W Slave_id_x
Stop Start
Slave_id+R
Stop
Start
Slave_id+W Slave_id_x
Stop Start
Slave_id+R
Stop
Master to Slave T =1,2,3… as Packet_CNT
Start
Slave_id+W Slave_id_x
Reg(T-1)_Addr_byte(0) …… Reg(T-1)_Addr_byte(M-1)
Slave_id+R
Stop
In Master mode, the CPU host controls the TWI engine by writing command and data to its registers. The TWI
engine transmits an interrupt to CPU when each time a byte transfer is done or a START/STOP command is
detected. The CPU host can poll the status register if the interrupt mechanism is not disabled by the CPU host.
When the CPU host wants to start a bus transfer, it initiates a bus START to enter the master mode by setting
TWI_CNTR[M_STA] to high. The TWI engine will assert the INT line and TWI_CNTR[INT_FLAG] to indicate a
completion for the START command and each consequent byte transfer. At each interrupt, the CPU host needs
Copyright©Allwinner Technology Co.,Ltd. All Rights Reserved. 829
Confidential
to check the current state by the TWI_STAT register. A transfer must conclude with the STOP command by
setting TWI_CNTR[M_STP] to high.
In Slave mode, the TWI engine also constantly samples the bus and look for its own slave address during
addressing cycles. Once a match is found, it is addressed, and the TWI engine interrupts the CPU host with the
corresponding status. Upon request, the CPU host should read the status, read/write the TWI_DATA register,
and set the TWI_CNTR register. After each byte transfer, a slave device always stops the operation of the
remote master by holding the next low pulse on the SCL line until the CPU host responds to the status of the
previous byte transfer or START command.
After the data transfer, if the master still requires the bus, it can signal another Start followed by another slave
address without signaling a Stop.
Figure 9-8 shows the TWI programming state diagram. For the value between two states, see the TWI_STAT
register in section 9.1.6.5.
C_IDLE: Idle.
ARB_LOST
arb_lost
M_SEND_S
M_SEND_ADDR
C_IDLE
M_SEND_XADD
M_RECV_DATA
M_SEND_SR
M_SEND_DATA
M_SEND_P
The TWI controller operates in an 8-bit data format. The data on the TWI_SDA line is always 8 bits long. At first,
the TWI controller sends a start condition. When in the addressing formats of 7-bit, the TWI sends out an 8-bit
message which includes 7 MSB slave address and 1 LSB read/write flag. The least significant of the salve address
indicates the direction of transmission. When the TWI works in 10-bit slave address mode, the operation will
be divided into two steps, for details on the operation, refer to register description in Section 9.1.6.1 and 9.1.6.2.
The following takes the TWI module in the CPUX domain as an example.
Step 2 For TWIn, set TWI_BGR_REG[TWIn_GATING] in CCU module to 0 to close TWIn clock.
Step 3 For TWIn, set TWI_BGR_REG[TWIn_RST] in CCU module to 0, then set to 1 to reset TWIn.
Step 4 For TWIn, set TWI_BGR_REG[TWIn_GATING] in CCU module to 1 to open TWIn clock.
Step 5 Configure TWI_CCR[CLK_M] and TWI_CCR[CLK_N] to get the needed rate (The clock source of TWI is
from APB1).
Step 6 Configure TWI_CNTR[BUS_EN] and TWI_CNTR[A_ACK], when using interrupt mode, set
TWI_CNTR[INT_EN] to 1, and register the system interrupt through PLIC module. In slave mode,
configure TWI_ADDR and TWI_XADDR registers to finish TWI initialization configuration.
Step 1 Clear TWI_EFR register, and configure TWI_CNTR[M_STA] to 1 to transmit the START signal.
Step 2 After the START signal is transmitted, the first interrupt is triggered, then write device ID to TWI_DATA
(For a 10-bit device ID, firstly write the first byte ID, secondly write the second byte ID in the next
interrupt).
Step 3 The Interrupt is triggered again after device ID transmission completes, write device data address to
be read to TWI_DATA (For a 16-bit address, firstly write the first-byte address, secondly write the
second-byte address).
Step 4 Interrupt is triggered after data address transmission completes, write data to be transmitted to
TWI_DATA (For consecutive write data operation, every byte transmission completion triggers
interrupt, during interrupt write the next byte data to TWI_DATA).
Step 5 After transmission completes, write TWI_CNTR[M_STP] to 1 to transmit the STOP signal and end this
write-operation.
Step 1 Clear TWI_EFR register, and set TWI_CNTR[A_ACK] to 1, and configure TWI_CNTR[M_STA] to 1 to
transmit the START signal.
Step 2 After the START signal is transmitted, the first interrupt is triggered, then write device ID to TWI_DATA
(For a 10-bit device ID, firstly write the first-byte ID, secondly write the second-byte ID in the next
interrupt).
Step 3 The Interrupt is triggered again after device ID transmission completes, write device data address to
be read to TWI_DATA (For a 16-bit address, firstly write the first-byte address, secondly write the
second-byte address).
Step 4 The Interrupt is triggered after data address transmission completes, write TWI_CNTR[M_STA] to 1 to
transmit new START signal, and after interrupt triggers, write device ID to TWI_DATA to start read-
operation.
Step 5 After device address transmission completes, each receive completion will trigger an interrupt, in turn,
read TWI_DATA to get data, when receiving the previous interrupt of the last byte data, clear [A_ACK]
to stop acknowledge signal of the last byte.
Step 6 Write TWI_CNTR[M_STP] to 1 to transmit the STOP signal and end this read-operation.
Step 2 For TWIn, set TWI_BGR_REG[TWIn_GATING] in CCU module to 0 to close TWIn clock.
Step 3 For TWIn, set TWI_BGR_REG[TWIn_RST] in CCU module to 0, then set to 1 to reset TWIn.
Step 4 For TWIn, set TWI_BGR_REG[TWIn_GATING] in CCU module to 1 to open TWIn clock.
Step 6 Configure TWI_DRV_BUS_CTRL[CLK_M] and TWI_DRV_BUS_CTRL[CLK_N] to get the needed rate (The
clock source of TWI is from APB1).
Step 8 When using DMA for data transmission, set TWI_DRV_DMA_CFG[DMA_RX_EN] and
TWI_DRV_DMA_CFG[DMA_TX_EN] to 1, and configure TWI_DRV_DMA_CFG[RX_TRIG] and
TWI_DRV_DMA_CFG[TX_TRIG] to set the thresholds of RXFIFO and TXFIFO.
Step 1 Configure TWI_DRV_SLV[SLV_ID] to set the device ID, and configure TWI_DRV_SLV[CMD] to 0 to set
the write operation.
Step 2 Configure TWI_DRV_FMT[ADDR_BYTE] according to the address width of the device register, and
TWI_DRV_FMT[DATA_BYTE] according to the written data count in a packet.
Step 4 Configure DMA channel, including TWI TXFIFO, device register address, and the written data.
Step 6 When TWI driver transmission completes, the interrupt is triggered, it indicates that the write packet
transmission ends.
Step 1 Configure TWI_DRV_SLV[SLV_ID] to set the device ID, and configure TWI_DRV_SLV[CMD] to 1 to set
the read operation.
Step 2 Configure TWI_DRV_FMT[ADDR_BYTE] according to the address width of the device register, and
TWI_DRV_FMT[DATA_BYTE] according to the read data count in a packet.
Step 4 Configure DMA channel, including TWI TXFIFO, TWI RXFIFO, device register address and the read data.
Step 6 When TWI driver transmission completes, the interrupt is triggered, it indicates that the read packet
transmission ends.
NOTE
9.1.6.18 0x0300 TWI_DRV Send Data FIFO Access Register (Default Value: 0x0000_0000)
9.1.6.19 0x0304 TWI_DRV Receive Data FIFO Access Register (Default Value: 0x0000_0000)
9.2 UART
9.2.1 Overview
The universal asynchronous receiver transmitter (UART) provides an asynchronous serial communication with
external devices, modem (data carrier equipment, DCE). It performs serial-to-parallel conversion on the data
received from peripherals and transmits the converted data to the internal bus. It also performs parallel-to-
serial conversion on the data that is transmitted to peripherals.
- Each of them is 256 bytes (For UART1, UART2, UART3, UART4, and UART5)
SGR
FIFO Modem
MC_SYNC Ctrl
TX_FIFO
(SYNC) TX sout
Regfile
RX_FIFO TO_DET
(ASYNC) RX sin
RXDMA
AHB
APB
The following figure shows the UART serial data format. The start bit, data bit, parity bit, and stop bit can be
configured.
One Character
One Bit
Figure 9-11 shows the typical application diagram for RTS/CTS autoflow control. Figure 9-12 shows the data
format of the RTS/CTS autoflow control.
SoC
UART-TX
TX
UART-RX External
RX
UART1/2/3 UART-RTS UART
RTS Device
UART-CTS CTS
CTS-
RX Start Data N Stop Start Data N+1 Stop Start Data N+2 Stop
RTS-
Figure 9-13 shows the application diagram for the IrDA transceiver. Figure 9-14 shows the data format of the
serial IrDA.
SoC
UART-TX
SIR_IN
UART-RX
SIR_OUT
UART1/2/3 UART-RTS
SD/MODE
UART-CTS
IrDA Transceiver
Data Bits
Bit Time
SIN/SOUT S Stop
3/16 Bit Time 3/16 Bit Time
SIR_OUT
3/16 Bit Time
SIR_IN
Figure 9-15 shows the application diagram for the RS-485 transceiver. Figure 9-16 shows the data format of
the RS-485.
SoC
UART-TX
DIN
UART-RX RS-485
DOUT
UART1/2/3 UART-RTS Transceiver
TXEN
UART-CTS RXEN
The UART_LCR register can set the basic parameter of a data frame: data width (5 to 8 bits), stop bit number
(1/1.5/2), parity type.
A frame transfer of the UART includes the start signal, data signal, parity bit, and stop signal. The LSB is
transmitted first.
Start signal (start bit): It is the start flag of a data frame. According to the UART protocol, the low level of
the TXD signal indicates the start of a data frame. When the UART transmits data, the level needs to hold
high.
Data signal (data bit): The data bit width can be configured as 5-bit, 6-bit, 7-bit, and 8-bit through different
applications.
Parity bit: It is a 1-bit error correction signal. Parity bit includes odd parity, even parity. The UART can
enable and disable the parity bit by setting the UART_LCR register.
Stop Signal (stop bit): It is the stop bit of a data frame. The stop bit can be set to 1-bit, 1.5-bit, and 2-bit
by the UART_LCR register. The high level of the TXD signal indicates the end of a data frame.
The SCLK is usually APB1 and can be set in section 3.3 “CCU”.
The divisor is frequency divider of UART. The frequency divider has 16-bit, the low 8-bit is in the UART_DLL
register, the high 8-bit is in the UART_DLH register.
The relationship between the different UART mode and the error rate is as follows.
DLAB Definition
The DLAB control bit (UART_LCR[7]) is the access control bit of the divisor Latch register.
If DLAB is 0, then the 0x00 offset address is the UART_RBR/UART_THR (RX/TX FIFO) register, and the 0x04
offset address is the UART_IER register.
If DLAB is 1, then the 0x00 offset address is the UART_DLL register, and the 0x04 offset address is the
UART_DLH register.
When the UART initials, the divisor needs to be set. That is, writing 1 to DLAB can access the UART_DLL and
UART_DLH register, after finished the configuration, writing 0 to DLAB can access the UART_RBR/UART_THR
register.
CHCFG_AT_BUSY Definition
The function of the CHCFG_AT_BUSY (UART_HALT[1]) and CHANGE_UPDATE (UART_HALT[2]) are as follows.
CHCFG_AT_BUSY: Enable the bit, the software can also set the UART controller when UART is busy, such as the
UART_LCR, UART_DLH, UART_DLL register.
Step 2 Write 1 to DLAB (UART_LCR[7]) and set the UART_DLH and UART_DLL registers.
Step 3 Write 1 to CHANGE_UPDATE to update the configuration. The bit is cleared to 0 automatically after
completing the update.
When the TX transmits data, or the RX receives data, or the TX FIFO is not empty, or the RX FIFO is not empty,
then the busy flag bit can be set to 1 by hardware, which indicates the UART controller is busy.
The following takes the UART module in the CPUX domain as an example.
9.2.4.1 Initialization
Configure APB1_CFG_REG in the CCU module to set the APB1 bus clock (The clock is 24MHz by
default).
IO configuration: Configure GPIO multiplex as UART function, and set UART pins to internal pull-
up mode (For detail, see the description in section 9.7 “GPIO”).
Baud-rate configuration:
Set UART_LCR[DLAB] to 1, remain default configuration for other bits; set 0x00 offset
address to the UART_DLL register, set 0x04 offset address to the UART_DLH register;
Write the high 8-bit of divisor to the UART_DLH register, and write the low 8-bit of divisor
to the UART_DLL register;
Set UART_LCR[DLAB] to 0, remain default configuration for other bits; set 0x00 offset
address to the UART_RBR/UART_THR register, set 0x04 offset address to the UART_IER
register;
Set data width, stop bits, and even/odd parity type by writing the UART_LCR register.
Reset, enable FIFO and set FIFO trigger condition by writing the UART_FCR register.
Configure UART interrupt vector number to request UART interrupt (Refer to section 3.8 “PLIC”
module for interrupt vector number).
Data transfer
Step 2 Check TX_FIFO status by reading UART_USR[TFNF]. If the bit is 1, data can continue to be written; if
the bit is 0, wait for data transfer, and data cannot continue to write until FIFO is not full.
Data receive
Data transfer
Step 3 When the data of TX_FIFO meets trigger condition (such as FIFO/2, FIFO/4), the UART transfer
interrupt is generated.
Step 4 Check UART_USR[TFE] and determine whether TX_FIFO is empty. If UART_USR[TFE] is 1, it indicates
that the data in TX_FIFO is transmitted completely.
Data receive
Step 2 When the received data from RX_FIFO meets trigger condition (such as FIFO/2, FIFO/4), the UART
receive interrupt is generated.
Step 4 Check RX_FIFO status by reading UART_USR[RFNE] and determine whether to read data. If the bit is
1, continue to read data from UART_RBR until UART_USR[RFNE] is cleared to 0, which indicates data
is received completely.
Data transfer
Step 1 Configure the UART DMA interrupt according to the initialization process.
Step 2 Configure DMA data channel, including the transfer source address, the transfer destination address,
the number of data to be transferred, and the transfer type, and so on. (For details, see section 3.9
“DMAC”).
Step 3 Enable the DMA transfer function of the UART by setting the register of the DMA module.
Step 4 Determine whether UART data is transferred completely based on the DMA status. If all data is
transferred completely, disable the DMA transfer function of the UART.
Data receive
Step 1 Configure DMA data channel, including the transfer source address, the transfer destination address,
the number of data to be transferred, and the transfer type, and so on. (For details, see section 3.9
“DMAC”).
Step 2 Enable the DMA receive function of the UART by setting the register of the DMA module.
Step 3 Determine whether UART data is received completely based on the DMA status. If all data is received
completely, disable the DMA receive function of the UART.
9.2.6.3 0x0000 UART Divisor Latch Low Register (Default Value: 0x0000_0000)
9.2.6.4 0x0004 UART Divisor Latch High Register (Default Value: 0x0000_0000)
9.2.6.14 0x0080 UART Transmit FIFO Level Register (Default Value: 0x0000_0000)
9.2.6.15 0x0084 UART Receive FIFO Level Register (Default Value: 0x0000_0000)
9.2.6.16 0x0088 UART DMA Handshake Configuration Register (Default Value: 0x0000_00A5)
9.2.6.21 0x00F0 UART FIFO Clock Control Register (Default Value: 0x0000_0003)
9.2.6.26 0x0110 UART RXDMA Buffer Start Address Low Register (Default Value: 0x0000_0000)
9.2.6.27 0x0114 UART RXDMA Buffer Start Address High Register (Default Value: 0x0000_0000)
9.2.6.28 0x0118 UART RXDMA Buffer Length Register (Default Value: 0x0000_0000)
9.2.6.29 0x0120 UART RXDMA Interrupt Enable Register (Default Value: 0x0000_0000)
9.2.6.30 0x0124 UART RXDMA Interrupt Status Register (Default Value: 0x0000_0000)
9.2.6.31 0x0128 UART RXDMA Write Address Low Register (Default Value: 0x0000_0000)
9.2.6.32 0x012C UART RXDMA Write Address High Register (Default Value: 0x0000_0000)
9.2.6.33 0x0130 UART RXDMA Read Address Low Register (Default Value: 0x0000_0000)
9.2.6.34 0x0134 UART RXDMA Read Address High Register (Default Value: 0x0000_0000)
9.2.6.35 0x0138 UART RXDMA Data Count Register (Default Value: 0x0000_0000)
9.3 SPI
9.3.1 Overview
The Serial Peripheral Interface (SPI) is a full-duplex, synchronous, four-wire serial communication interface
between a CPU and SPI-compliant external devices. The SPI controller contains a 64 x 8 bits receiver buffer
(RXFIFO) and a 64 x 8 bits transmit buffer (TXFIFO). It can work in master mode and slave mode.
Master/slave configurable
8-bit wide by 64-entry FIFO for both transmit and receive data
Polarity and phase of the Chip Select (SPI_SS) and SPI Clock (SPI_SCLK) are configurable
Supports standard SPI, dual-output/dual-input SPI, dual I/O SPI, quad-output/quad-input SPI
spi_top
spi_mosi_oen
spi_mosi_out
tbuf txfifo spi_tx
spi_miso_oen
spi_miso_out
AHB sckt
spi_ss_oen
spi_ss_out
spi_ss_in
TX DMA spi_rf spi_cmu spi_sck_oen
spi_sck_out
spi_sck_in
RX DMA
sckr
spi_mosi_in
rbuf rxfifo spi_rx
INTC spi_miso_in
hclk sclk
domain domain
Sub-block Description
Responsible for implementing the internal register, interrupt, and DMA
spi_rf
Request.
The data length transmitted from AHB to TXFIFO is converted into 8 bits,
spi_tbuf
then the data is written into the RXFIFO.
The block is used to convert the RXFIFO data into the reading data length
spi_rbuf
of AHB.
The data transmitted from the SPI to the external serial device is written
txfifo, rxfifo into the TXFIFO; the data received from the external serial device into SPI
is pushed into the RXFIFO.
Responsible for implementing SPI bus clock, chip select, internal sample,
spi_cmu
and the generation of transfer clock.
Responsible for implementing SPI data transfer, the interface of the
spi_tx
internal TXFIFO, and status register.
Responsible for implementing SPI data receive, the interface of the
spi_rx
internal RXFIFO, and status register.
The following table describes the external signals of SPI. The MOSI and MISO are bidirectional I/O, when SPI is
as a master device, the CLK and CS are the output pin; when SPI is as a slave device, the CLK and CS are the
input pin. When using SPI, the corresponding PADs are selected as SPI function via section 9.7 “GPIO”.
The SPI controller gets 5 different clock sources, users can select one of them to make SPI clock source. The
following table describes the clock sources for SPI. For more details on the clock setting, configuration, and
gating information, see section 3.3 “CCU”.
Figure 9-21 shows the application block diagram when the SPI master device is connected to a slave device.
SoC
SPI-CLK
SCK
SPI-CS
CS# SPI-
SPI-MISO
SO/IO1 compliant
SPI SPI-MOSI SI/IO0 External
SPI-WP Device
WP#/IO2
SPI-HOLD
HOLD#/IO3
The SPI supports 4 different formats for data transfer. The software can select one of the four modes in which
the SPI works by setting the bit1 (Polarity) and bit0 (Phase) of SPI_TCR. The SPI controller master uses the
SPI_SCLK signal to transfer data in and out of the shift register. Data is clocked using any one of four
programmable clock phase and polarity combinations.
The CPOL (SPI_TCR[1]) defines the polarity of the clock signal (SPI_SCLK). The SPI_SCLK is a high level when
CPOL is ‘1’ and it is a low level when CPOL is ‘0’. The CPHA (SPI_TCR[0]) decides whether the leading edge of
SPI_SCLK is used to setup or sample data. The leading edge is used to setup data when CPHA is ‘1’, and sample
data when CPHA is ‘0’. The following table lists the four modes.
Figure 9-22 and Figure 9-23 describe four waveforms for SPI_SCLK.
The SPI controller can be configured to a master or slave device. The master mode is selected by setting the
MODE bit (SPI_GCR[1]); the slave mode is selected by clearing the MODE bit.
In master mode, the SPI_CLK is generated and transmitted to the external device, and the data from the TX
FIFO is transmitted on the MOSI pin, the data from the slave device is received on the MISO pin and sent to RX
FIFO. The Chip Select (SPI_SS) is an active low signal, and it must be set low before the data are transmitted or
received. The SPI_SS can be selected the auto control mode or software manual control mode. When using the
auto control, the SS_OWNER (SPI_TCR[6]) must be cleared (default value is 0); when using the manual control,
the SS_OWNER must be set. And the level of SPI_SS is controlled by SS_LEVEL (SPI_TCR[7]).
In slave mode, after the software selects the MODE bit (SPI_GCR[1]) to '0', it waits for master initiate a
transaction. When the master asserts SPI_SS, then SPI_CLK is transmitted to the slave device, the slave data is
transmitted from TX FIFO on the MISO pin and the data from the MOSI pin is received in RX FIFO.
The SPI 3-wire mode is only valid when the SPI controller work in master mode, and is selected when the Work
Mode Select bit (SPI_BATC[1:0]) is equal to 0x2. And in the 3-wire mode, the input data and the output data
use the same single data line. The following figure describes the 3-wire mode.
The dual read mode (SPI x2) is selected when the DRM is set in SPI_BCC[28]. Using the dual mode allows data
to be transferred to or from the device at double the rate of standard single mode, the data can be read at fast
speed using two data bits (MOSI and MISO) at a time. The following figure describes the dual-input/dual-output
SPI (Figure 9-25) and the dual I/O SPI (Figure 9-26).
In the dual-input/dual-output SPI mode, the command, address, and the dummy bytes output in a unit of a
single bit in serial mode through the SPI_MOSI line, only the data bytes are output (write) and input (read) in
a unit of dual bits through the SPI_MOSI and SPI_MISO.
In the dual I/O SPI mode, only the command bytes output in a unit of a single bit in serial mode through the
SPI_MOSI line. The address bytes and the dummy bytes output in a unit of dual bits through the SPI_MOSI and
SPI_MISO. And the data bytes output (write) and input (read) in a unit of dual bits through the SPI_MOSI and
SPI_MISO.
The quad read mode (SPI x4) is selected when the Quad_EN is set in SPI_BCC[29]. Using the quad mode allows
data to be transferred to or from the device at 4 times the rate of standard single mode, the data can be read
at fast speed using four data bits (MOSI, MISO, IO2 (WP#) and IO3 (HOLD#)) at the same time. The following
figure describes the quad-input/quad-output SPI.
In the quad-input/quad-output SPI mode, the command, address, and the dummy bytes output in a unit of a
single bit in serial mode through SPI_MOSI line. Only the data bytes output (write) and input (read) in a unit of
quad bits through the SPI_MOSI, SPI_MISO, SPI_WP#, and SPI_HOLD#.
In SPI master mode, the transmission and reception bursts (byte in unit) are configured before the SPI transfers
the serial data between the processor and external device. The transmission bursts are written in MWTC
(bit[23:0]) of the SPI Master Transmit Counter Register. The transmission bursts in single mode before
automatically sending dummy bursts are written in STC (bit[23:0]) of the SPI Master Transmit Counter Register.
For dummy data, the SPI controller can automatically send before receiving by writing DBC (bit[27:24]) in the
SPI Master Transmit Counter Register. If users do not use the SPI controller to send dummy data automatically,
then the dummy bursts are used as the transmission counters to write together in MWTC (bit[23:0]) of the SPI
Master Transmit Counter Register. In master mode, the total burst numbers are written in MBC (bit[23:0]) of
the SPI Master Transmit Counter Register. When all transmission and reception bursts are transferred, the SPI
controller will send a completed interrupt, at the same time, the SPI controller will clear DBC, MWTC, and MBC.
The SPI controller runs at 3 kHz–100 MHz at its interface to external SPI devices. The internal SPI clock should
run at the same frequency as the outgoing clock in the master mode. The SPI clock is selected from different
clock sources, the SPI must configure different work mode. There are three work modes: normal sample mode,
delay half-cycle sample mode, delay one-cycle sample mode. The Delay half-cycle sample mode is the default
mode of the SPI controller. When the SPI runs at 40 MHz or below 40 MHz, the SPI can work at normal sample
mode or delay half-cycle sample mode. When the SPI runs over 80 MHz, setting the SDC bit in the SPI Transfer
Control Register to ‘1’ makes the internal read sample point with a half-cycle delay of SPI_CLK, which is used in
high speed read operation to reduce the error caused by the time delay of SPI_CLK between master and slave.
Table 9-10 and Table 9-11 show the different configurations of the SPI sample mode.
CAUTION
The remaining spectrum is not recommended. Because when the output delay of SPI flash (refer to the
datasheet of the manufactures for the specific delay time) is the same with the half-cycle time of SPI working
clock, the variable edge of the output data for the device bumps into the clock sampling edge of the controller,
so setting 1 cycle of sampling delay would cause stability problem.
If any error conditions occur, the hardware will set the corresponding status bits in the SPI Interrupt Status
Register and stop the transfer. For the SPI controller, the following error scenarios can happen.
1. TX_FIFO Underrun
The TX_FIFO underrun happens when the CPU/DMA reads data from TX FIFO when it is empty. In the case,
the SPI controller will end the transaction and flag the error bit along with the TF_UDF bit in the SPI
Interrupt Status Register. The SPI controller will generate an interrupt if interrupts are enabled. The
software has to clear the error bit and the TF_UDF bit. To start a new transaction, the software has to reset
the FIFO by writing to the SRST (soft reset) bit in the SPI Global Control Register.
2. TX_FIFO Overflow
The TX_FIFO overflow happens when the CPU/DMA writes data into the TX FIFO when it is full. In the case,
the SPI controller will end the transaction and flag the error bit along with the TF_OVF bit in the SPI
Interrupt Status Register. The SPI controller will generate an interrupt if interrupts are enabled. The
software has to clear the error bit and the TF_OVF bit. To start a new transaction, the software has to reset
the FIFO by writing to the SRST (soft reset) bit in the SPI Global Control Register.
3. RX_FIFO Underrun
The RX_FIFO underrun happens when the CPU/DMA reads data from RX FIFO when it is empty. In the case,
the SPI controller will end the transaction and flag the error bit along with the RF_UDF bit in the SPI
Interrupt Status Register. The SPI controller will generate an interrupt if interrupts are enabled. The
software has to clear the error bit and the RF_UDF bit. To start a new transaction, the software has to reset
the fifo by writing to the SRST (soft reset) bit in the SPI Global Control Register.
4. RX_FIFO Overflow
The RX_FIFO overflow happens when the CPU/DMA writes data into the RX FIFO when it is full. In the case,
the SPI controller will end the transaction and flag the error bit along with the RF_OVF bit in the SPI
Interrupt Status Register. The SPI controller will generate an interrupt if interrupts are enabled. The
software has to clear the error bit and the RF_OVF bit. To start a new transaction, the software has to reset
the FIFO by writing to the SRST (soft reset) bit in the SPI Global Control Register.
The SPI transfers serial data between the processor and the external device. The CPU mode and DMA mode
are the two main operational modes for SPI. For each SPI, the data is simultaneously transmitted (shifted out
serially) and received (shifted in serially). The SPI has 2 channels, including the TX channel and RX channel. The
TX channel has the path from TX FIFO to the external device. The RX channel has the path from the external
device to RX FIFO.
Write Data: The CPU or DMA must write data on the SPI_TXD register, the data on the register are
automatically moved to TX FIFO.
Read Data: To read data from RX FIFO, the CPU or DMA must access the SPI_RXD register and the data are
automatically sent to the SPI_RXD register.
In CPU or DMA mode, the SPI sends a completed interrupt (SPI_ISR[TC]) to the processor after each
transmission is complete.
CPU Mode
DMA Mode
The SPI has one delay chain which is used to generate delay to make proper timing between the internal SPI
clock signal and data signals. Delay chain is made up of 64 delay cells. The delay time of one delay cell can be
estimated through delay chain calibration.
Step 1 Enable SPI. To calibrate the delay chain by the operation registers in SPI, the SPI must be enabled
through AHB reset and AHB clock gating control registers.
Step 2 Configure a proper clock for SPI. The calibration delay chain is based on the clock for SPI from CCU.
Step 3 Set proper initial delay value. Write 0xA0 to the SPI Sample Delay Control Register to set initial delay
value 0x20 to delay chain. Then write 0x0 to the SPI Sample Delay Control Register to clear this value.
Step 4 Write 0x8000 to the SPI Sample Delay Control Register to start to calibrate the delay chain.
Step 5 Wait until the flag (bit14 in the SPI Sample Delay Control Register) of calibration done is set. The
number of delay cells is shown at the bit[13:8] of the SPI Sample Delay Control Register. The delay
time generated by these delay cells is equal to the cycle of the SPI clock nearly. This value is the result
of calibration.
Step 6 Calculate the delay time of one delay cell according to the cycle of the SPI clock and the result of
calibration.
9.3.6.8 0x0028 SPI Sample Delay Control Register (Default Value: 0x0000_2000)
9.3.6.9 0x0030 SPI Master Burst Counter Register (Default Value: 0x0000_0000)
9.3.6.10 0x0034 SPI Master Transmit Counter Register (Default Value: 0x0000_0000)
9.3.6.11 0x0038 SPI Master Burst Control Counter Register (Default Value: 0x0000_0000)
9.3.6.12 0x0040 SPI Bit-Aligned Transfer Configure Register (Default Value: 0x0000_00A0)
9.3.6.13 0x0044 SPI Bit-Aligned CLOCK Configuration Register (Default Value: 0x0000_0000)
9.3.6.16 0x0088 SPI Normal DMA Mode Control Register (Default Value: 0x0000_00E5)
9.4 SPI_DBI
9.4.1 Overview
The F133 provides a 3/4 line SPI display bus interface (SPI_DBI) for video data transmission. It supports DBI
mode or SPI mode. The DBI mode is compatible with multiple video data formats at the same time. The SPI
mode is used for low-cost display schemes.
Master/slave configurable
8-bit wide by 64-entry FIFO for both transmit and receive data
Polarity and phase of the Chip Select (SPI_SS) and SPI Clock (SPI_SCLK) are configurable
Supports standard SPI, dual-output/dual-input SPI, dual I/O SPI, quad-output/quad-input SPI
Maximum resolution of RGB888 240 x 320@60Hz or 320 x 480@30Hz with dual data lane
spi_ctrl
spi_mosi/wp/hold_oen
spi_mosi/wp/hold_out
spi_tx
spi_miso_oen
spi_miso_out
sckt
spi_ss_oen[3:0]
spi_ss_out[3:0]
spi_ss_in[3:0]
spi_cmu
spi_top spi_sck_oen
spi_sck_out
spi_sck_in
sckr
tbuf txfifo spi_mosi_in
spi_rx
spi_miso_in
sclk
domain
spi_rf MUX
MUX
GPIO
DBI_TypeC
dbi_sda_oen
dbi_sda_out
rbuf rxfifo dbi_tx dbi_wrx_oen
INTC dbi_wrx_out
sckt
dbi_csx_oen
hclk dbi_csx_out
domain dbi_dcx_oen
dbi_ctrl dbi_dcx_out
dbi_scl_oen
dbi_scl_out
dbi_sdi_oen
sckr
dbi_sda_in
dbi_rx
dbi_sdi_in
pixel_clk
domain
Sub-block Description
Responsible for implementing the internal register, interrupt, and DMA
spi_rf
Request.
The data length transmitted from AHB to TXFIFO is converted into 8 bits,
spi_tbuf
then the data is written into the RXFIFO.
The block is used to convert the RXFIFO data into the reading data length
spi_rbuf
of AHB.
The data transmitted from the SPI to the external serial device is written
txfifo, rxfifo into the TXFIFO; the data received from the external serial device into SPI
is pushed into the RXFIFO.
Responsible for implementing SPI bus clock, chip select, internal sample,
spi_cmu
and the generation of transfer clock.
Responsible for implementing SPI data transfer, the interface of the
spi_tx
internal TXFIFO, and status register.
Sub-block Description
Responsible for implementing SPI data receive, the interface of the
spi_rx
internal RXFIFO, and status register.
Responsible for implementing DBI bus clock, chip select, data command
dbi_ctrl
select, RGB format reshape.
Responsible for implementing DBI data transfer, the interface of the
dbi_tx
internal TXFIFO, and status register.
Responsible for implementing DBI data receive, the interface of the
dbi_rx
internal RXFIFO, and status register.
The following table describes the external signals of SPI_DBI. When using SPI_DBI, the corresponding PADs are
selected as SPI_DBI function via section 9.7 “GPIO”.
The SPI_DBI controller gets 5 different clock sources, users can select one of them to make SPI_DBI clock source.
The following table describes the clock sources for SPI_DBI. For more details on the clock setting, configuration,
and gating information, see section 3.3 “CCU”.
Figure 9-31 shows the application block diagram when the SPI master device is connected to a slave device.
SoC
SPI-CLK
SCK
SPI-CS
CS# SPI-
SPI-MISO
SO/IO1 compliant
SPI SPI-MOSI SI/IO0 External
SPI-WP Device
WP#/IO2
SPI-HOLD
HOLD#/IO3
Figure 9-32 shows the application block diagram when the DBI master device is connected to a display bus
interface device.
SoC
DBI-CSX
CSX
DBI-SCLK
SCLK Display
DBI-DCX
DBI D/CX bus
DBI-SDI SDI interface
DBI-SDO device
SDO
The SPI supports 4 different formats for data transmission. The software can select one of the four modes in
which the SPI works by setting the bit1 (Polarity) and bit0 (Phase) of SPI_TCR. The SPI controller master uses
the SPI_SCLK signal to transfer data in and out of the shift register. Data is clocked using any one of four
programmable clock phase and polarity combinations.
The CPOL (SPI_TCR[1]) defines the polarity of the clock signal (SPI_SCLK). The SPI_SCLK is a high level when
CPOL is ‘1’ and it is a low level when CPOL is ‘0’. The CPHA (SPI_TCR[0]) decides whether the leading edge of
SPI_SCLK is used to setup or sample data. The leading edge is used to setup data when CPHA is ‘1’, and sample
data when CPHA is ‘0’. The following table lists the four modes.
SPI Mode Polarity (CPOL) Phase (CPHA) Leading Edge Trailing Edge
mode0 0 0 Sample on the rising edge Setup on the falling edge
mode1 0 1 Setup on the rising edge Sample on the falling edge
Sample on the falling
mode2 1 0 Setup on the rising edge
edge
mode3 1 1 Setup on the falling edge Sample on the rising edge
Figure 9-33 and Figure 9-34 describe four waveforms for SPI_SCLK.
The SPI controller can be configured to a master or slave device. The master mode is selected by setting the
MODE bit (SPI_GCR[1]); the slave mode is selected by clearing the MODE bit.
In master mode, the SPI_CLK is generated and transmitted to the external device, and the data from the TX
FIFO is transmitted on the MOSI pin, the data from the slave is received on the MISO pin and sent to RX FIFO.
The Chip Select (SPI_SS) is an active low signal, and it must be set low before the data are transmitted or
received. The SPI_SS can be selected the auto control mode or the software manual control mode. When using
auto control, the SS_OWNER (SPI_TCR[6]) must be cleared (default value is 0); when using manual control, the
SS_OWNER must be set. And the level of SPI_SS is controlled by SS_LEVEL (SPI_TCR[7]).
In slave mode, after the software selects the MODE bit (SPI_GCR[1]) to '0', it waits for master initiate a
transaction. When the master asserts SPI_SS, and SPI_CLK is transmitted to the slave, the slave data is
transmitted from TX FIFO on the MISO pin, and the data from the MOSI pin is received in RX FIFO.
The SPI 3-wire mode is only valid when the SPI controller work in master mode, and is selected when the Work
Mode Select bit (SPI_BATC[1:0]) is equal to 0x2. And in the 3-wire mode, the input data and the output data
use the same single data line. The following figure describes the 3-wire mode.
The dual read mode (SPI x2) is selected when the DRM is set in SPI_BCC[28]. Using the dual mode allows data
to be transferred to or from the device at double the rate of standard single mode SPI devices, the data can be
read at fast speed using two data bits (MOSI and MISO) at a time. The following figure describes the dual-
input/dual-output SPI (Figure 9-36) and the dual I/O SPI (Figure 9-37).
In the dual-input/dual-output SPI mode, the command, address, and the dummy bytes output in a unit of a
single bit in serial mode through the SPI_MOSI line, only the data bytes are output (write) and input (read) in
a unit of dual bits through the SPI_MOSI and SPI_MISO.
In the dual I/O SPI mode, only the command bytes output in a unit of a single bit in serial mode through the
SPI_MOSI line. The address bytes and the dummy bytes output in a unit of dual bits through the SPI_MOSI and
SPI_MISO. And the data bytes output (write) and input (read) in a unit of dual bits through the SPI_MOSI and
SPI_MISO.
The quad read mode (SPI x4) is selected when the Quad_EN is set in SPI_BCC[29]. Using the quad mode allows
data to be transferred to or from the device at 4 times the rate of standard single mode SPI devices, the data
can be read at fast speed using four data bits (MOSI, MISO, IO2 (WP#) and IO3 (HOLD#)) at the same time. The
following figure describes the quad-input/quad-output SPI.
In the quad-input/quad-output SPI mode, the command, address, and the dummy bytes output in a unit of a
single bit in serial mode through the SPI_MOSI line. Only the data bytes output (write) and input (read) in a
unit of quad bits through the SPI_MOSI, SPI_MISO, SPI_WP#, and SPI_HOLD#.
In SPI master mode, the transmission and reception bursts (byte in unit) are configured before the SPI transfers
serial data between the processor and external device. The transmission bursts are written in MWTC (bit[23:0])
of the SPI Master Transmit Counter Register. The transmission bursts in single mode before automatically
sending dummy bursts are written in STC (bit[23:0]) of the SPI Master Transmit Counter Register. For dummy
data, the SPI controller can automatically send before receiving by writing DBC (bit[27:24]) in the SPI Master
Transmit Counter Register. If users do not use the SPI controller to send dummy data automatically, then the
dummy bursts are used as the transmission counters to write together in MWTC (bit[23:0]) of the SPI Master
Transmit Counter Register. In master mode, the total burst numbers are written in MBC (bit[23:0]) of the SPI
Master Transmit Counter Register. When all transmission and reception bursts are transferred, the SPI
controller will send a completed interrupt, at the same time, the SPI controller will clear DBC, MWTC, and MBC.
The SPI controller runs at 3 kHz–100 MHz at its interface to external SPI devices. The internal SPI clock should
run at the same frequency as the outgoing clock in the master mode. The SPI clock is selected from different
clock sources, the SPI must configure different work mode. There are three work modes: normal sample mode,
delay half-cycle sample mode, delay one-cycle sample mode. Delay half-cycle sample mode is the default mode
of the SPI controller. When the SPI runs at 40 MHz or below 40 MHz, the SPI can work at normal sample mode
or delay half-cycle sample mode. When the SPI runs over 80 MHz, setting the SDC bit in the SPI Transfer Control
Register to ‘1’ makes the internal read sample point with a half-cycle delay of SPI_CLK, which is used in high
speed read operation to reduce the error caused by the time delay of SPI_CLK between master and slave. Table
9-16 and Table 9-17 show the different configurations of the SPI sample mode.
CAUTION
The remaining spectrum is not recommended. Because when the output delay of SPI flash (refer to the
datasheet of the manufactures for the specific delay time) is the same with the half-cycle time of SPI working
clock, the variable edge of the output data for the device bumps into the clock sampling edge of the controller,
so setting 1 cycle of sampling delay would cause stability problem.
The 3-line DBI Interface I contains CSX, SDA, and SCL, where SDA shares this port for bidirectional port data
input and output.
The 3-line DBI Interface II contains CSX, SDA, SCL, and SDI; Data input and output ports are independent of each
other.
Since the 3-line display bus mode has no Data/Command data line indicating whether Data or Command is
currently being transmitted, an extra bit is added to the data-stream before MSB to indicate whether Data or
Command is currently being transmitted. (0: Command, 1: Data)
The following figure shows the writing operation format of 3-line DBI Interface I and Interface II.
Figure 9-39 DBI 3-Line Display Bus Serial Interface Writing Operation Format
SCL
The CSX can be high level between the data and next
command. The SDA and SCL are invalid during CSX is
high level.
The 3-line DBI Interface I uses the SDA port as bidirectional data input and output port. There are only three
cases of data reading volume, 8bits/24bits/32bits, and the first data sampled is high.
The following figure shows the 8 bits reading operation format of 3-line DBI Interface I and Interface II. After
the read command is transmitted, the data is read immediately with on dummy period.
Figure 9-40 DBI 3-Line Display Bus Serial Interface 8-bit Reading Operation Format
SCL
Interface I SDA 0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
Hi-Z
SDO 0 D7 D6 D5 D4 D3 D2 D1 D0
Interface II
SDI Hi-Z D7 D6 D5 D4 D3 D2 D1 D0
The following figure shows the 24 bits reading operation format of 3-line DBI Interface I and Interface II. After
the read command is transmitted, the data is read after waiting for the dummy clock cycle.
Figure 9-41 DBI 3-Line Display Bus Serial Interface 24-bit Reading Operation Format
SCL
Hi-Z
SDO 0 D7 D6 D5 D4 D3 D2 D1 D0
Interface II Hi-Z
SDI D23 D22 D21 D2 D1 D0
The following figure shows the 32 bits reading operation format of 3-line DBI Interface I and Interface II. After
the read command is transmitted, the data is read after waiting for the dummy clock cycle.
Figure 9-42 DBI 3-Line Display Bus Serial Interface 32-bit Reading Operation Format
SCL
Hi-Z
SDO 0 D7 D6 D5 D4 D3 D2 D1 D0
Interface II Hi-Z
SDI D31 D30 D29 D2 D1 D0
The 4-line DBI Interface I contains CSX, D/CX, SDA, and SCL, where SDA shares this port for bidirectional port
data input and output.
The 4-line DBI Interface II contains CSX, D/CX, SDA, SCL, and SDI; Data input and output ports are independent
of each other.
Since the 4-line display bus mode has a Data/Command data line indicating whether Data or Command is
currently being transmitted (0: Command, 1: Data). So there is no need to add an extra bit to data-stream
before MSB like the 3-line DBI.
The following figure shows the writing operation format of 4-line DBI Interface I and Interface II.
Figure 9-43 DBI 4-Line Display Bus Serial Interface Writing Operation Format
D/CX
Host
SDA D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL
The following figure shows the 8 bits reading operation format of 4-line DBI Interface I and Interface II.
Figure 9-44 DBI 4-Line Display Bus Serial Interface 8-bit Reading Operation Format
D/CX
SCL
Interface I
SDA D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
Hi-Z
SDO D7 D6 D5 D4 D3 D2 D1 D0
Interface II
SDI Hi-Z D7 D6 D5 D4 D3 D2 D1 D0
The following figure shows the 24 bits reading operation format of 4-line DBI Interface I and Interface II.
Figure 9-45 DBI 4-Line Display Bus Serial Interface 24-bit Reading Operation Format
D/CX
SCL
Hi-Z
SDO D7 D6 D5 D4 D3 D2 D1 D0
Interface II Hi-Z
SDI D23 D22 D21 D2 D1 D0
The following figure shows the 32 bits reading operation format of 4-line DBI Interface I and Interface II.
Figure 9-46 DBI 4-Line Display Bus Serial Interface 32-bit Reading Operation Format
D/CX
SCL
Hi-Z
SDO D7 D6 D5 D4 D3 D2 D1 D0
Interface II Hi-Z
SDI D31 D30 D29 D2 D1 D0
CSX
Pixel n Pixel n+ 1
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
SDA 1 - - R1 G1 B1 R2 G2 B2 1 - - R3 G3 B3 R4 G4 B4 1 - - R5 G5 B5 R6 G6 B6
WRX/SCL
3 bits 3 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
SDA 1 R1 3 R1 2 R1 1 R1 0 G13 G12 G11 G10 1 B1 3 B1 2 B1 1 B1 0 R2 3 R2 2 R2 1 R2 0 1 G23 G2 2 G21 G20 B2 3 B22 B21 B2 0
Pixel n Pixel n+ 1
SCL
12 bits 12 bits
Loop-up table for 4096 color data mapping (12 bits to 18 bits)
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
Pixel n Pixel n+ 1
SCL
16 bits 16 bits
Loop-up table for 65k color data mapping (16 bits to 18 bits)
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
Pixel n
SCL
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
CSX
D/CX 1 1 1
Pixel n Pixel n+ 1
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SDA - - R1 G1 B1 R2 G2 B2 - - R3 G3 B3 R4 G4 B4 - - R5 G5 B5 R6 G6 B6
WRX/SCL
3 bits 3 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D/CX
“1”
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
Pixel n Pixel n+ 1
SCL
12 bits 12 bits
Loop-up table for 4096 color data mapping (12 bits to 18 bits)
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D/CX
“1”
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
Pixel n Pixel n+ 1
SCL
16 bits 16 bits
Loop-up table for 65k color data mapping (16 bits to 18 bits)
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D/CX
“1”
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SDA R1 5 R1 4 R13 R12 R1 1 R1 0 - - G1 5 G14 G1 3 G12 G1 1 G10 - - B15 B1 4 B13 B1 2 B11 B10 - -
Pixel n
SCL
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
For RGB444:
RESX
“1”
CSX
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
SDA 1 B1 3 B1 2 B1 1 B10 - - - - 1 B1 3 B1 2 B1 1 B1 0 - - - -
Pixel n Pixel n+ 1
SCL
12 bits 12 bits
Lo op-up table for 4096 color data mapping (12 bits to 18 bits)
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
D8 D7 D6 D5 D4 D3 D2 D1 D0 D8 D7 D6 D5 D4 D3 D2 D1 D0
Pixel n Pixel n+ 1
SCL
16 bits 16 bits
Loop-up table for 65k color data mapp ing (16 bits to 18 bits)
18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
RESX
“1”
CSX
D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Pixel n Pixel n+ 1
SCL
18 bits 18 bits
Frame Memory
R1 G1 B1 R2 G2 B2 R3 G3 B3
Figure 9-58 RGB666 2 Data Lane Interface Transmit Video Format 1 (ilitek)
18 bit/pixel color order (R:6-bit, G:6-bit, B:6-bit), 262, 144 colors, Type1
S TB TB TB
CSX
Host SDA 1 R5 R4 R3 R2 R1 R0 1 B5 B4 B3 B2 B1 B0 1 G5 G4 G3 G2 G1 G0
(MCU to Driver)
D/CX(SDA2) 1 G5 G4 G3 G2 G1 G0 1 R5 R4 R3 R2 R1 R0 1 B5 B4 B3 B2 B1 B0
SCL
Pixel data 1 B5~B0: Pixel data 1 Pixel data 2
R5~R0: Pixel data 2
Figure 9-59 RGB666 2 Data Lane Interface Transmit Video Format 2 (New vision)
RGB666,mdt=01
CSX
SCL
SDA A0 R5 R4 R3 R2 R1 R0 A0 B5 B4 B3 B2 B1 B0 A0 G5 G4 G3 G2 G1 G0
WRX A0 G5 G4 G3 G2 G1 G0 A0 R5 R4 R3 R2 R1 R0 A0 B5 B4 B3 B2 B1 B0
RGB888
CSX
SDA_0 1 R7 R6 R5 R4 R3 R2 R1 R0 G7 G6 G5 G4 1 R7 R6 R5 R4
SDA_1 1 G3 G2 G1 G0 B7 B6 B5 B4 B3 B2 B1 B0 1 G3 G2 G1 G0
SCL
The SPI transfers serial data between the processor and the external device. CPU and DMA are the two main
operational modes for SPI. For each SPI, the data is simultaneously transmitted (shifted out serially) and
received (shifted in serially). The SPI has 2 channels, including the TX channel and RX channel. The TX channel
has the path from TX FIFO to the external device. The RX channel has the path from the external device to RX
FIFO.
Write Data: CPU or DMA must write data on the SPI_TXD register, the data on the register are automatically
moved to TX FIFO.
Read Data: To read data from RX FIFO, CPU or DMA must access the register SPI_RXD and data are
automatically sent to the register SPI_RXD.
In CPU or DMA mode, the SPI sends a completed interrupt (SPI_ISR[TC]) to the processor at the end of each
transfer.
CPU Mode
DMA Mode
The SPI has one delay chain which is used to generate delay to make proper timing between the internal SPI
clock signal and data signals. Delay chain is made up of 64 delay cells. The delay time of one delay cell can be
estimated through delay chain calibration.
Step 1 Enable SPI. To calibrate the delay chain by operation registers in SPI, the SPI must be enabled through
AHB reset and AHB clock gating control registers.
Step 2 Configure a proper clock for SPI. The calibration delay chain is based on the clock for SPI from CCU.
Step 3 Set proper initial delay value. Write 0xA0 to the SPI Sample Delay Control Register to set initial delay
value 0x20 to delay chain. Then write 0x0 to the SPI Sample Delay Control Register to clear this value.
Step 4 Write 0x8000 to the SPI Sample Delay Control Register to start to calibrate the delay chain.
Step 5 Wait until the flag (Bit14 in the SPI Sample Delay Control Register) of calibration done is set. The
number of delay cells is shown at Bit[13:8] in SPI Sample Delay Control Register. The delay time
generated by these delay cells is equal to the cycle of SPI’s clock nearly. This value is the result of
calibration.
Step 6 Calculate the delay time of one delay cell according to the cycle of the SPI clock and the result of
calibration.
Step 1 Set the SPI_DBI_MODE_SEL (bit3) of SPI_GCR (0x0004) to 1 to select DBI mode.
Step 2 Set the DBI EN MODE SEL (bit[30:29]) of DBI_CTL_1 (0x0104) to 0 to select the trigger mode of DBI.
Set DBI_CTL_0[Write Command Dummy Cycles] (bit[30:20]) to configure the number of dummy
cycles between commands.
Set DBI_CTL_0[DBI interface Select] (bit[10:8]) to select the DBI interface type.
The remaining values of the DBI_CTL_0 register remain the default value.
Set SPI_FCR[TX_TRIG_LEVEL] (bit[23:16]) to 255. It indicates the controller requests data from
DMA if the remaining space of TX FIFO is greater than 255.
Step 7 Wait until the TX FIFO underrun interrupt (SPI_ISR[TF_UDF]) is 1. It indicates that the command
written to the TX FIFO is transmitted completely.
Step 1 Set the SPI_DBI_MODE_SEL (bit3) of SPI_GCR (0x0004) to 1 to select DBI mode.
Step 2 Set the DBI EN MODE SEL (bit[30:29]) of DBI_CTL_1 (0x0104) to 0 to select the trigger mode of DBI.
Set DBI_CTL_0[Write Command Dummy Cycles] (bit[30:20]) to configure the number of dummy
cycles between commands.
Set DBI_CTL_0[DBI interface Select] (bit[10:8]) to select the DBI interface type.
The remaining values of the DBI_CTL_0 register remain the default value.
Set SPI_FCR[TX_TRIG_LEVEL] (bit[23:16]) to 255. It indicates the controller requests data from
DMA if the remaining space of TX FIFO is greater than 255.
Step 7 Wait until the TX FIFO underrun interrupt (SPI_ISR[TF_UDF]) is 1. It indicates that the command
written to the TX FIFO is transmitted completely.
If the data is from the CPU path, the controller writes the command to be sent to the 0x0200 address by the
AHB bus.
If the data is from the DMA path, configure DBI_CTL_1[DBI_FIFO_DRQ_EN] (bit15) to 1 and
DBI_CTL_1[TX_TRIG_LEVEL] (bit[14:8]) to 64, which indicates the controller requests data from DMA if the
remaining space of TX FIFO is greater than 64.
After transmitting each frame image, the controller clears automatically the line_cnt, pixel_cnt and stops
transmitting data.
Wait for the edge interrupt of TE, the software needs to enable DBI_en_trigger, in circulation.
Step 1 Set the SPI_DBI_MODE_SEL (bit3) of SPI_GCR (0x0004) to 1 to select DBI mode.
Step 2 Set the DBI EN MODE SEL (bit[30:29]) of DBI_CTL_1 (0x0104) to 1 to select the software trigger mode.
Set DBI_CTL_0[Write Command Dummy Cycles] (bit[30:20]) to configure the number of dummy
cycles between commands.
Set DBI_CTL_0[DBI interface Select] (bit[10:8]) to select the DBI interface type.
The remaining values of the DBI_CTL_0 register remain the default value.
The software configures timer_en to enable timer counting, and when the counter reaches the specified value,
the DBI_EN automatically can be enabled to start transmitting data.
After transmitting each frame image, the controller clears automatically the line_cnt, pixel_cnt, and stops
transmitting data.
The timer starts counting again. When the counter reaches the specified value, the controller automatically
enables DBI_EN, and in circulation until the software turns off the timer_en.
Step 1 Set the SPI_DBI_MODE_SEL (bit3) of SPI_GCR (0x0004) to 1 to select DBI mode.
Step 2 Set the DBI EN MODE SEL (bit30:29) of DBI_CTL_1 (0x0104) to 2 to select the timer trigger mode.
Set DBI_CTL_0[Write Command Dummy Cycles] (bit[30:20]) to configure the number of dummy
cycles between commands.
Set DBI_CTL_0[DBI interface Select] (bit[10:8]) to select the DBI interface type.
The remaining values of the DBI_CTL_0 register remain the default value.
TE Trigger Mode
When the edge changes of the TE are detected (The rising and falling edges are optional), the DBI_EN
automatically can be enabled to start transmitting data.
After transmitting each frame image, the controller clears automatically the line_cnt, pixel_cnt, and stops
transmitting data.
When the edge changes of the TE are detected (The rising and falling edges are optional), the DBI_EN
automatically can be enabled to start transmitting data until the software shuts down TE_EN or the screen no
longer sends TE signals.
Step 1 Set the SPI_DBI_MODE_SEL (bit3) of SPI_GCR (0x0004) to 1 to select DBI mode.
Step 2 Set the DBI EN MODE SEL (bit30:29) of DBI_CTL_1 (0x0104) to 3 to select the TE trigger mode.
Set DBI_CTL_0[Write Command Dummy Cycles] (bit[30:20]) to configure the number of dummy
cycles between commands.
Set DBI_CTL_0[DBI interface Select] (bit[10:8]) to select the DBI interface type.
The remaining values of the DBI_CTL_0 register remain the default value.
9.4.4.6 Transmitting Read Command and Read Data Using DBI Mode
Step 1 Set the SPI_DBI_MODE_SEL (bit3) of SPI_GCR (0x0004) to 1 to select DBI mode.
Set DBI_CTL_0[DBI interface Select] (bit[10:8]) to select the DBI interface type.
The remaining values of the DBI_CTL_0 register remain the default value.
Configure DBI_CTL_1[Read_MSB_First] (bit20) to select whether the first bit of the read data is
the highest or lowest bit of data.
Configure DBI_CTL_1[Read Data Number of Bytes] to set the byte number to be read.
Configure DBI_CTL_1[Read Command Dummy Cycles] to set the dummy cycle between the read
command and the read data, when the dummy cycle is complete, the data starts to be sampled.
Set SPI_FCR[RX_TRIG_LEVEL] (bit[7:0]) to 32, which indicates the controller requests receiving
data from DMA if the data of the RX FIFO is greater than 64.
Step 7 Wait until DBI_INT[RD_DONE_INT] is 1. It indicates that the data is read completely.
9.4.6.8 0x0028 SPI Sample Delay Control Register (Default Value: 0x0000_2000)
9.4.6.9 0x0030 SPI Master Burst Counter Register (Default Value: 0x0000_0000)
9.4.6.10 0x0034 SPI Master Transmit Counter Register (Default Value: 0x0000_0000)
9.4.6.11 0x0038 SPI Master Burst Control Counter Register (Default Value: 0x0000_0000)
9.4.6.12 0x0040 SPI Bit-Aligned Transfer Configure Register (Default Value: 0x0000_00A0)
9.4.6.13 0x0044 SPI Bit-Aligned Clock Configuration Register (Default Value: 0x0000_0000)
9.4.6.16 0x0088 SPI Normal DMA Mode Control Register (Default Value: 0x0000_00E5)
9.5.1 Overview
The USB2.0 dual-role device (USB2.0 DRD) supports both device and host functions which can also be
configured as a Host-only or Device-only controller. It complies with the USB2.0 Specification.
For saving CPU bandwidth, the DMA interface of the DRD module can also support the external DMA controller
to do the data transfer between the memory and the DRD FIFO. The DRD core also supports USB power saving
functions.
- Compatible with Enhanced Host Controller Interface (EHCI) Specification, Version 1.0
- Compatible with Open Host Controller Interface (OHCI) Specification, Version 1.0a
- Supports High-Speed (HS, 480 Mbit/s), Full-Speed (FS, 12 Mbit/s), and Low-Speed (LS, 1.5 Mbit/s)
- Supports only 1 USB Root port shared between EHCI and OHCI
- Up to 10 user-configurable endpoints (EP1+, EP1-, EP2+, EP2-, EP3+, EP3-, EP4+, EP4-, EP5+, EP5-) for
Bulk transfer, Isochronous transfer and Interrupt transfer
Supports point-to-point and point-to-multipoint transfer in both Host and Peripheral modes
The following figure shows the block diagram of USB2.0 DRD Controller.
USB2.0 DRD
Device AHB Slave Interface
9.6.1 Overview
The USB Host Controller is fully compliant with USB 2.0 Specification, Enhanced Host Controller Interface (EHCI)
Specification Revision 1.0 and Open Host Controller Interface (OHCI) Specification Release 1.0a.
- Compatible with Enhanced Host Controller Interface (EHCI) Specification, Version 1.0
- Compatible with Open Host Controller Interface (OHCI) Specification, Version 1.0a
- Supports High-Speed (HS, 480 Mbit/s), Full-Speed (FS, 12 Mbit/s) and Low-Speed (LS, 1.5 Mbit/s)
Device
- Supports only 1 USB Root port shared between EHCI and OHCI
The following figure shows the block diagram of USB2.0 Host Controller.
USB2.0 Host
Host1 AHB Slave Interface
Host1 Master Interface
USB DM1 & DP1
EHCI1 IRQ UTMI PHY1
Host1
OHCI1 IRQ
VDD-SYS VCC-IO
SIE Control
Register
DP
USB
OHCI SCLK PHY DM
Gating 48M
Device
DCXO24M MUL FS/LS
12M OHCI
DIV
PLL_PERIPH
PHY Reset/Gating
9.6.5.2 0x0002 EHCI Host Interface Version Number Register (Default Value:0x0100)
9.6.5.3 0x0004 EHCI Host Control Structural Parameter Register (Default Value:0x0000_1101)
9.6.5.4 0x0008 EHCI Host Control Capability Parameter Register (Default Value:0x0000_A026)
NOTE
This register must be written as a DWord. Byte writes produce undefined results.
9.6.5.10 0x0024 EHCI Periodic Frame List Base Address Register (Default Value:0x0000_0000)
NOTE
9.6.5.11 0x0028 EHCI Current Asynchronous List Address Register (Default Value:0x0000_0000)
NOTE
NOTE
9.6.5.13 0x0054 EHCI Port Status and Control Register (Default Value:0x0000_2000)
8 R/W 0x0
Note that when software writes a zero to this bit there may be a
delay before the bit status changes to a zero. The bit status will not
read as a zero until after the reset has completed. If the port is in
high-speed mode after reset is complete, the host controller will
automatically enable this port (e.g. set the Port Enable bit to a
one). A host controller must terminate the reset and stabilize the
state of the port within 2 milliseconds of software transitioning this
bit from a one to a zero. For example: if the port detects that the
attached device is high-speed during reset, then the host
controller must have the port in the enabled state with 2ms of
software writing this bit to a zero.
2 R/W 0x0 Ports can only be enabled by the host controller as a part of the
reset and enable. Software cannot enable a port by writing a one
to this field. The host controller will only set this bit to a one when
the reset sequence determines that the attached device is a high-
speed device.
NOTE
9.6.6.18 0x0448 OHCI Root Hub DescriptorA Register (Default Value: 0x0200_1201)
NoPowerSwithcing
These bits are used to specify whether power switching is
supported or ports are always powered. It is implementation-
8 R/W R 0x0 specific. When this bit is cleared, the PowerSwitchingMode
specifies global or per-port switching.
0 Ports are power switched.
1 Ports are always powered on when the HC is powered on.
NumberDownstreamPorts
These bits specify the number of downstream ports supported by
7:0 R R 0x01
the Root Hub. It is implementation-specific. The minimum
number of ports is 1. The maximum number of ports supported.
(write)SetRemoteWakeupEnable
Writing a ‘1’ sets DeviceRemoveWakeupEnable. Writing a ‘0’ has
no effect.
14:2 / / / /
OverCurrentIndicator
This bit reports overcurrent conditions when the global reporting
is implemented. When set, an overcurrent condition exists. When
1 R R/W 0x0
cleared, all power operations are normal.
If per-port overcurrent protection is implemented this bit is
always ‘0’
(Read)LocalPowerStatus
When read, this bit returns the LocalPowerStatus of the Root Hub.
The Root Hub does not support the local power status feature;
thus, this bit is always read as ‘0’.
(Write)ClearGlobalPower
0 R/W R 0x0
When write, this bit is operated as the ClearGlobalPower. In global
power mode (PowerSwitchingMode=0), This bit is written to ‘1’
to turn off power to all ports (clear PortPowerStatus). In per-port
power mode, it clears PortPowerStatus only on ports whose
PortPowerControlMask bit is not set. Writing a ‘0’ has no effect.
(write)ClearPortPower
The HCD clears the PortPowerStatus bit by writing a ‘1’ to this bit.
Writing a ‘0’ has no effect.
(read)PortPowerStatus
This bit reflects the port’s power status, regardless of the type of
power switching implemented. This bit is cleared if an overcurrent
condition is detected. HCD sets this bit by writing SetPortPower
or SetGlobalPower. HCD clears this bit by writing ClearPortPower
or ClearGlobalPower. Which power control switches are enabled
is determined by PowerSwitchingMode and
PortPortControlMask[NumberDownstreamPort]. In global
switching mode(PowerSwitchingMode=0), only
Set/ClearGlobalPower controls
this bit. In per-port power switching (PowerSwitchingMode=1), if
the PortPowerControlMask[NDP] bit for the port is set, only
8 R/W R/W 0x1 Set/ClearPortPower commands are enabled. If the mask is not
set, only Set/ClearGlobalPower commands are enabled. When
port power is disabled, CurrentConnectStatus, PortEnableStatus,
PortSuspendStatus, and PortResetStatus should be reset.
0 port power is off
1 port power is on
(write)SetPortPower
The HCD writes a ‘1’ to set the PortPowerStatus bit. Writing a ‘0’
has no effect.
(write)SetPortReset
The HCD sets the port reset signaling by writing a ‘1’ to this bit.
Writing a ‘0’ has no effect. If CurrentConnectStatus is cleared, this
write does not set PortResetStatus, but instead sets
ConnectStatusChange. This informs the driver that it attempted
to reset a disconnected port.
(read)PortOverCurrentIndicator
This bit is only valid when the Root Hub is configured in such a way
that overcurrent conditions are reported on a per-port basis. If
per-port overcurrent reporting is not supported, this bit is set to
0. If cleared, all power operations are normal for this port. If set,
an overcurrent condition exists on this port. This bit always
3 R/W R/W 0x0 reflects the overcurrent input signal.
0 no overcurrent condition.
1 overcurrent condition detected.
(write)ClearSuspendStatus
The HCD writes a ‘1’ to initiate a resume. Writing a ‘0’ has no
effect. A resume is initiated only if PortSuspendStatus is set.
(read)PortSuspendStatus
This bit indicates the port is suspended or in the resume sequence.
It is set by a SetSuspendState write and cleared when
PortSuspendStatusChange is set at the end of the resume
interval. This bit cannot be set if CurrentConnectStatus is cleared.
This bit is also cleared when PortResetStatusChange is set at the
end of the port reset or when the HC is placed in the USBRESUME
2 R/W R/W 0x0 state. If an upstream resume is in progress, it should propagate to
the HC.
0 port is not suspended
1 port is suspended
(write)SetPortSuspend
The HCD sets the PortSuspendStatus bit by writing a ‘1’ to this bit.
Writing a ‘0’ has no effect. If CurrentConnectStatus is cleared, this
(write)SetPortEnable
The HCD sets PortEnableStatus by writing a ‘1’. Writing a ‘0’ has
no effect. If CurrentConnectStatus is cleared, this write does not
set PortEnableStatus, but instead sets ConnectStatusChange.
This informs the driver that it attempted to enable a disconnected
Port.
(read)CurrentConnectStatus
This bit reflects the current state of the downstream port.
0 No device connected
1 Device connected
(write)ClearPortEnable
0 R/W R/W 0x0
The HCD writes a ‘1’ to clear the PortEnableStatus bit. Writing ‘0’
to this bit has no effect. The CurrentConnectStatus is not affected
by any write.
Note: This bit is always read ‘1’ when the attached device is
nonremovalble (DviceRemoveable[NumberDownstreamPort]).
9.6.6.26 0x0828 HCI SIE Port Disable Control Register (Default Value: 0x0000_0000)
9.7 GPIO
9.7.1 Overview
The general purpose input/output (GPIO) is one of the blocks controlling the chip multiplexing pins. The F133
supports 6 groups of GPIO pins. Each pin can be configured as input or output and these pins are used to
generate input signals or output signals for special purposes.
Up to 72 interrupts
The GPIO consists of the digital part (GPIO, external interface) and IO analog part (output buffer, dual pull down,
pad). The digital part can select the output interface by the MUX switch; the analog part can configure pull
up/down and buffer strength.
When executing GPIO read state, the GPIO reads the current level of the pin into the internal register bus.
When not executing GPIO read state, the external pin and the internal register bus are off-status, which is high-
impedance.
The F133 includes 72 multi-functional input/output port pins. There are 6 ports as listed below.
LCD/LVDS/OWA/TWI/IR/DSI/SPI-DBI/DMIC/ 3.3 V/
PD 23 Schmitt CMOS
UART/PWM/IR/PD-EINT 1.8 V
SMHC/UART/PWM/I2S/TWI/EMAC/OWA/ 3.3 V/
PG 16 Schmitt CMOS
IR/TCON/LEDC/SPI/PG-EINT 1.8 V
Table 9-21 to Table 9-26 show the multiplex function pins of the F133.
NOTE
For each GPIO, Function0 is input function; Function1 is output function; Function9 to Function13 are reserved.
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
SPI1-MISO/
PD13 LCD0-D19 LVDS1-V1N UART3-RTS PD-EINT13
DBI-SDI/DBI-TE/
DBI-DCX
SPI1-HOLD/
PD14 LCD0-D20 LVDS1-V2P UART3-CTS PD-EINT14
DBI-DCX/
DBI-WRX
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
RGMII-RXCTRL/
PE0 NCSI0-HSYNC UART2-RTS TWI1-SCK LCD0-HSYNC PE-EINT0
RMII-CRS-DV
RGMII-RXD0/
PE1 NCSI0-VSYNC UART2-CTS TWI1-SDA LCD0-VSYNC PE-EINT1
RMII-RXD0
RGMII-RXD1/
PE2 NCSI0-PCLK UART2-TX TWI0-SCK CLK-FANOUT0 UART0-TX PE-EINT2
RMII-RXD1
RGMII-TXCK/
PE3 NCSI0-MCLK UART2-RX TWI0-SDA CLK-FANOUT1 UART0-RX PE-EINT3
RMII-TXCK
RGMII-TXD0/
PE4 NCSI0-D0 UART4-TX TWI2-SCK CLK-FANOUT2 R-JTAG-MS PE-EINT4
RMII-TXD0
RGMII-TXD1/
PE5 NCSI0-D1 UART4-RX TWI2-SDA LEDC-DO R-JTAG-DI PE-EINT5
RMII-TXD1
RGMII-TXCTRL/
PE6 NCSI0-D2 UART5-TX TWI3-SCK OWA-IN R-JTAG-DO PE-EINT6
RMII-TXEN
RGMII-CLKIN/
PE7 NCSI0-D3 UART5-RX TWI3-SDA OWA-OUT R-JTAG-CK PE-EINT7
RMII-RXER
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
GPIO Port Function 2 Function 3 Function 4 Function 5 Function 6 Function 7 Function 8 Function 14
RGMII-RXCTRL/
PG0 SDC1-CLK UART3-TX PWM7 PG-EINT0
RMII-CRS-DV
RGMII-RXD0/
PG1 SDC1-CMD UART3-RX PWM6 PG-EINT1
RMII-RXD0
RGMII-RXD1/
PG2 SDC1-D0 UART3-RTS UART4-TX PG-EINT2
RMII-RXD1
RGMII-TXCK/
PG3 SDC1-D1 UART3-CTS UART4-RX PG-EINT3
RMII-TXCK
RGMII-TXD0/
PG4 SDC1-D2 UART5-TX PWM5 PG-EINT4
RMII-TXD0
RGMII-TXD1/
PG5 SDC1-D3 UART5-RX PWM4 PG-EINT5
RMII-TXD1
RGMII-TXCTRL/
PG12 I2S1-LRCK TWI0-SCK CLK-FANOUT2 PWM0 UART1-TX PG-EINT12
RMII-TXEN
RGMII-CLKIN/
PG13 I2S1-BCLK TWI0-SDA PWM2 LEDC-DO UART1-RX PG-EINT13
RMII-RXER
The Port Controller supports 6 GPIOs, every GPIO can configure as Input, Output, Function Peripheral, IO
disable or Interrupt function. The configuration instruction of every function is as follows.
Y: configure
N: Forbid to configure
VCC
Rpu
PAD
Rpd
GND
High-impedance, the output is float state, all buffer is off, the level is decided by external high/low level. When
high-impedance, the software configures the switch on Rpu and Rpd as off, and the multiplexing function of IO
is set as IO disable or input by software.
Pull-up, an uncertain signal is pulled high by resistance, the resistance has a current-limiting function. When
pulling up, the switch on Rpu is conducted by software configuration, the IO is pulled up to VCC by Rpu.
Pull-down, an uncertain signal is pulled low by a resistance. When pulling down, the switch on Rpd is conducted
by software configuration, the IO is pulled down to GND by Rpd.
Each IO can be set as different buffer strength. The IO buffer diagram is as follows.
VCC
P0 P1 P2 P3
ro ro ro ro
ro ro ro ro
n0 n1 n2 n3
GND
When output high level, the n0, n1, n2, n3 of NMOS is off, the p0, p1, p2, p3 of PMOS is on. When the buffer
strength is set to 0 (buffer strength is weakest), only the p0 is on, the output impedance is maximum, the
impedance value is r0. When the buffer strength is set to 1, only the p0 and p1 is on, the output impedance is
equivalent to two r0 in parallel, the impedance value is r0/2. When the buffer strength is 2, only the p0, p1,
and p2 is on, the output impedance is equivalent to three r0 in parallel, the impedance value is r0/3. When
buffer strength is 3, the p0, p1, p2, and p3 is on, the output impedance is equivalent to four r0 in parallel, the
impedance value is r0/4.
When output low level, the p0, p1, p2, p3 of PMOS is off, the n0, n1, n2, n3 of NMOS is on. When the buffer
strength is set to 0 (buffer strength is weakest), only the n0 is on, the output impedance is maximum, the
impedance value is r0. When the buffer strength is set to 1, only the n0 and n1 is on, the output impedance is
equivalent to two r0 in parallel, the impedance value is r0/2. When the buffer strength is 2, only the n0, n1,
and n2 is on, the output impedance is equivalent to three r0 in parallel, the impedance value is r0/3. When the
buffer strength is 3, the n0, n1, n2, and n3 is on, the output impedance is equivalent to four r0 in parallel, the
impedance value is r0/4.
When GPIO is set to input or interrupt function, between the output driver circuit and the port is unconnected,
the driver configuration is invalid.
NOTE
9.7.3.6 Interrupt
Each group IO has an independent interrupt number. The IO within-group uses one interrupt number when
one IO generates interrupt, the GPIO pins sent interrupt request to interrupt module. External Interrupt Status
Register is used to query which IO generates interrupt.
Positive Edge: When a low level changes to a high level, the interrupt will generate. No matter how long
a high level keeps, the interrupt generates only once.
Negative Edge: When a high level changes to a low level, the interrupt will generate. No matter how long
a low level keeps, the interrupt generates only once.
High Level: Just keep a high level and the interrupt will always generate.
Low Level: Just keep a low level and the interrupt will always generate.
The GPIO interrupt supports hardware debounce function by setting External Interrupt Debounce Register.
Sample trigger signal using a lower sample clock, to reach the debounce effect because the dither frequency
of the signal is higher than the sample frequency.
Set the sample clock source by PIO_INT_CLK_SELECT and the prescale factor by DEB_CLK_PRE_SCALE.
9.7.5.64 0x0340 PIO Group Withstand Voltage Mode Select Register (Default Value: 0x0000_0000)
When the power domain of GPIO is larger than 1.8 V, the withstand voltage is set to 3.3 V mode, the
corresponding value in the 0x0340 register is set to 0.
When the power domain of GPIO is 1.8 V, the withstand voltage is set to 1.8 V mode, the corresponding value
in the 0x0340 register is set to 1.
Offset: 0x0340 Register Name: PIO_POW_MOD_SEL
Bit Read/Write Default/Hex Description
31:13 / / /
VCCIO_PWR_MOD_SEL
VCC_IO POWER MODE Select
12 R/W 0x0
0: 3.3 V
1: 1.8 V
11:7 / / /
PG_PWR_MOD_SEL
PG_POWER MODE Select
6 R/W 0x0 0: 3.3 V
1: 1.8 V
If PG_Port Power Source selects VCC_IO, this bit is invalid.
9.7.5.65 0x0344 PIO Group Withstand Voltage Mode Select Control Register (Default Value: 0x0000_0000)
For 1.8 V and 3.3 V power, the withstand function is enabled by default, the corresponding bit in the 0x0344
register is set to 0.
For 2.5 V power, the withstand function is disabled, the corresponding bit in the 0x0344 register is set to 1, and
the corresponding withstand voltage in the 0x0340 register needs to be set to 3.3 V.
Offset: 0x0344 Register Name: PIO_POW_MS_CTL
Bit Read/Write Default/Hex Description
31:13 / / /
VCCIO_WS_VOL_MOD_SEL
VCC_IO Withstand Voltage Mode Select Control
12 R/W 0x0
0: Enable
1: Disable
9.7.5.66 0x0348 PIO Group Power Value Register (Default Value: 0x0000_0000)
When the reading value of the 0x0348 register is 0, it indicates that the IO power voltage is greater than 2.5 V.
When the reading value of the 0x0348 register is 1, it indicates that the IO power voltage is less than 2.0 V.
Offset: 0x0348 Register Name: PIO_POW_VAL
Bit Read/Write Default/Hex Description
31:17 / / /
VCCIO_PWR_VAL
16 R 0x0
VCC_IO Power Value
15:7 / / /
9.7.5.67 0x0350 PIO Group Power Voltage Select Control Register (Default Value: 0x0000_0001)
9.8 GPADC
9.8.1 Overview
The General Purpose ADC (GPADC) can convert the external signal into a certain proportion of digital value, to
realize the measurement of analog signal, which can be applied to power detection and key detection. This
ADC is a type of successive approximation register (SAR) A/D converter.
Power reference voltage: AVCC, and analog input voltage range: 0 to AVCC
Digital
GPADC0 ADC Logic Reg
Process
Vref IRQ
The GPADC has one clock source. The following table describes the clock source for GPADC. Users can see
section 3.3 “CCU” for clock setting, configuration, and gating information.
The GPADC completes one conversion in a specified channel, the converted data is updated at the data register
of the corresponding channel.
The GPADC has continuous conversion in a specified channel until the software stops, the converted data is
updated at the data register of the corresponding channel.
The GPADC samples and converts in a specified channel, and sequentially stores the results in FIFO.
CLK_IN = 24 MHz
Copyright©Allwinner Technology Co.,Ltd. All Rights Reserved. 1137
Confidential
TACQ > 10RC (R is output impedance of ADC sample circuit, C = 6.4 pF)
TACQ CONV_TIME
Where:
VREF = 1.8 V
Start
Enable GPADC
(1).Query Mode
Step 2 Write 0x1 to the bit[0] of GPADC_BGR_REG to enable the GPADC clock.
Step 3 Write 0x2F to the bit[15:0] of GP_SR_CON to set the acquiring time of ADC.
Step 4 Write 0x1DF to the bit[31:16] of GP_SR_CON to set the ADC sample frequency divider.
Step 5 Write 0x2 to the bit[19:18] of GP_CTRL to set the continuous conversion mode.
Step 6 Write 0x1 to the bit[0] of GP_CS_EN to enable the analog input channel.
Step 7 Write 0x1 to the bit[16] of GP_CTRL to enable the ADC function.
Step 8 Read the bit[0] of GP_DATA_INTS, if the bit is 1, then data conversion is complete.
Step 9 Read the bit[11:0] of GP_CH0_DATA, and calculate voltage value based on GPADC formula.
(2).Interrupt Mode
Step 2 Write 0x1 to the bit[0] of GPADC_BGR_REG to enable the GPADC clock.
Step 3 Write 0x2F to the bit[15:0] of GP_SR_CON to set the acquiring time of ADC.
Step 4 Write 0x1DF to the bit[31:16] of GP_SR_CON to set the ADC sample frequency divider.
Step 5 Write 0x2 to the bit[19:18] of GP_CTRL to set the continuous conversion mode.
Step 6 Write 0x1 to the bit[0] of GP_CS_EN to enable the analog input channel.
Step 7 Write 0x1 to the bit[0] of GP_DATA_INTC to enable the GPADC data interrupt.
Step 10 Write 0x1 to the bit16 of GP_CTRL to enable the ADC function.
Step 11 Read the bit[11:0] of GP_CH0_DATA from the interrupt handler, calculate voltage value based on
GPADC formula.
9.8.6.1 0x0000 GPADC Sample Rate Configure Register (Default Value: 0x01DF_002F)
9.8.6.3 0x0008 GPADC Compare and Select Enable Register (Default Value: 0x0000_0000)
9.8.6.4 0x000C GPADC FIFO Interrupt Control Register (Default Value: 0x0000_1F00)
9.8.6.5 0x0010 GPADC FIFO Interrupt Status Register (Default Value: 0x0000_0000)
9.8.6.8 0x0020 GPADC Low Interrupt Configure Register (Default Value: 0x0000_0000)
9.8.6.9 0x0024 GPADC High Interrupt Configure Register (Default Value: 0x0000_0000)
9.8.6.10 0x0028 GPADC DATA Interrupt Configure Register (Default Value: 0x0000_0000)
9.8.6.11 0x0030 GPADC Low Interrupt Status Register (Default Value: 0x0000_0000)
9.8.6.12 0x0034 GPADC High Interrupt Status Register (Default Value: 0x0000_0000)
9.8.6.13 0x0038 GPADC Data Interrupt Status Register (Default Value: 0x0000_0000)
9.8.6.14 0x0040 GPADC CH0 Compare Data Register (Default Value: 0x0BFF_0400)
9.9 TPADC
9.9.1 Overview
The Touch Panel ADC (TPADC) is a 4-wire resistive touch screen controller, including a 12-bit SAR type A/D
converter.
The controller is a typical type of successive approximation ADC (SAR ADC) which contains a sample/hold,
analog-to-digital conversion, serial data output functions.
The analog inputs (X+, X-, Y+, Y-) enter the ADC through the control register, the ADC can work in single-ended
or differential mode. Selecting Aux ADC should work in single-ended mode; for a touch screen application, it
works in a differential mode, which can effectively eliminate the impact on conversion accuracy caused by the
parasitic resistance of the driver switch and external interference.
Figure 9-73 shows TPADC Single-Ended Mode for the measurement of Aux, using the 1.8 V reference source as
the ADC reference voltage.
VCC_REF(3V)
X+
+IN +REF
X- 4:1
Converter
MUX
Y+ -IN
-REF
Y-
Figure 9-74 shows TPADC differential mode for the measurement of X/Y/Z coordinate of Touch Panel. The
advantage of differential mode: +REF and –REF can directly input to the Y+ and Y-(or X+ and X-), which can
eliminate the measurement error of X+/X-(or Y+/Y-) because of the switch on resistance. The disadvantage is
that: both the sample or conversion process, the driver will need to be enabled. Compared with single-ended
mode, the power consumption increases.
VCC_REF(3V)
+IN +REF
Converter
-IN
-REF
The following figure shows the operation principle of the single touch X-Coordinate measurement.
MEASURE
X POSITION
X+
TOUCH
X-POSITION
X-
For an X coordinate measurement, the X+ pin is internally switched to VCC_REF and X- to GND. The X plate
becomes a potential divider, and the voltage at the point of contact is proportional to its X co-ordinate. This
voltage is measured on the Y+, which carries no current (hence there is no voltage drop in RY+ or RY-). Due to
the ratio metric measurement method, the supply voltage does not affect measurement accuracy. The voltage
references VREF+ and VREF- are taken from after the matrix switches, so that any voltage drop in these
switches has no effect on the ADC measurement.
Y coordinate measurements are similar to X coordinate measurements, with the X and Y plates interchanged.
In single touch mode, it only needs to test X+ and Y+ signals. But in dual touch mode, it needs to test X+, X-, Y+,
and Y- signals. The following figure shows the operation principle of dual touch detection for touch panel.
MEASURE
X+ X+ Position
TOUCH
X-POSITION
X-
MEASURE
X- Position
For X coordinates measurement, the X+ pin is internally switched to 3 V and X- to GND. The controller needs
to test Y+ and Y-, Y coordinates measurement is similar. And record △X=|X+ - X-|, △Y= | Y+ - Y-|. In practice,
we can set a threshold. If △X or △Y is greater than the threshold, we consider it as a dual touch, otherwise as
a single touch.
The pressure applied to the touch screen by a pen or finger to filter unavailable can also be measured by the
controller using some simple calculations. The contact resistance between the X and Y plates is measured,
which provides a good indication of the size of the depressed area and the applied pressure. The area of the
touch spot t is proportional to the size of the object touching it. And the value of this resistance (Rtouch) can be
calculated using two different methods.
MEASURE MEASURE
X-POSITION Z1-POSITION
Y+
X+ X+ Y+ X+ Y+
TOUCH TOUCH
X- Y- X- Y- X- Y-
MEASURE
Z2-POSITION
The first method requires the user to know the total resistance of the X plate tablet (RXPLATE). Three touch
screen conversions are required: measurement of the X position, XPOSITION(Y+ input); measurement of the
X+ input with the excitation voltage applied to Y+ and X− (Z1 measurement); and measurement of the Y−
input with the excitation voltage applied to Y+ and X− (Z2 measurement). These three measurements are
illustrated in following Figure. The controller have two special ADC channel settings to configure the X and
Y switches for the Z1 and Z2 measurements and store the results in the Z1 and Z2 result registers. The
touch resistance (RTOUCH) can then be calculated using the following equation.
The second method requires the user to know the resistance of the X-plate and Y-plate tablets. Three touch
screen conversions are required: a measurement of the X position (XPOSITION), the Y position (YPOSITION), and
the Z1 position. The following equation also calculates the touch resistance (RTOUCH).
Pen down detection is used as an interrupt to the host. RIRQ is an internal pull-up resistor with a programmable
value from 6 kΩ to 96 kΩ (default 48 kΩ).
AVCC
RIRQ
ADC
X+ Y+
RTOUCH
X- Y-
The pen down IRQ output is pulled high by an internal pull-up. In the pen down detection, the Y– driver is
enabled and connected to GND, and the pen down IRQ output is connected to the X+ input. When the panel is
touched, the X+ input is pulled to ground through the touch screen, and the pen down IRQ output goes low
because of the current path through the panel to GND, initiating an interrupt to the processor.
During the measurement cycle for X-, Y-, and Z-position, the X+ input is disconnected from the pen down IRQ
pull-down transistor to eliminate any pull-up resistor leakage current from flowing through the touch screen,
thus causing no errors.
Touch screens are composed of two resistive layers, normally placed over an LCD screen. Because these layers
are in close proximity to the LCD screen, noise can be coupled from the screen onto these resistive layers,
causing errors in the touch screen positional measurements.
The controller contain a filtering block to process the data and discard the spurious noise before sending the
information to the host. The purpose of this block is not only the suppression of noise; the on-chip filtering also
greatly reduces the host processing loading.
The processing function consists of two filters that are applied to the converted results: the median filter and
the averaging filter. The median filter suppresses the isolated out-of-range noise and sets the number of
measurements to be taken. These measurements are arranged in a temporary array, where the first value is
the smallest measurement and the last value is the largest measurement. Then the averaging filter size
determines the number of values to average. There are four choices which is configured by TP_CTRL3 register
(bit 1 and bit 0) to filtrate the ADC sampling data.
Example: In this example, the bit[1:0] of TP_CTRL_REG3 is configured as 2’b11. So the median filter has a
window size of 16. This means that 16 measurements are taken and arranged in descending order in a
temporary array. The averaging window size in this example is 8. The output is the average of the middle eight
values of the 16 measurements taken with the median filter.
CHAN0–3 can be selected at the same time. If N channel is selected, each channel has 1/N full speed of the
ADC. If only one channel is selected, it has the full conversion rate. CHAN0–3 correspond to TP_YN, TP_YP,
TP_XN, TP_XP.
In touch panel mode, the data stored in this register bases on TP_FIFO_MODE_SELECT. In Auxiliary ADC mode,
the data stored in this register bases on ADC_CHAN_SELECT. If four channels are enabled, FIFO will access the
input data in successive turn (ADC_CHAN0 -> ADC_CHAN1 -> ADC_CHAN2 -> ADC_CHAN3). If only two or three
channels are selected, such as ADC_CHAN0 and ADC_CHAN3, firstly ADC_CHAN0 input data is accessed, then
ADC_CHAN3 input data.
9.10 PWM
9.10.1 Overview
The Pulse Width Modulation (PWM) module can output the configurable PWM waveforms and measure the
external input waveforms.
- Supports PWM pulse mode output, and the pulse number is configurable
- PWM01 pair (PWM0 + PWM1), PWM23 pair (PWM2 + PWM3), PWM45 pair (PWM4 + PWM5),
PWM67 pair (PWM6 + PWM7)
- Supports any plural channels to form a group, and output the same duty-cycle pulse
- In group mode, the relative phase of the output waveform for each channel is configurable
- Supports rising edge detection and falling edge detection for input waveform pulse
The PWM includes multi PWM channels. Each channel can generate different PWM waveform by the
independent counter and duty-ratio configuration register. Each PWM pair shares one group of clock and dead-
zone generator to generate PWM waveform.
PWM67
PWM45
PWM23
PWM01
Module Generator
PWM01 Clock PWM01_CLK
Controller
PWM1 Logic PWM1 GPIO
I/O
Module
Each PWM pair consists of 1 clock module, 2 timer logic module, and 1 programmable dead-zone generator.
Using PWM01 as an example. The other PWM pairs are the same as PWM01.
PWM01_CLK_DIV_M PWM0_PRESCAL_K
PWM0_CLK_GATING
The clock controller of each PWM pair includes clock source select (PWM01_CLK_SRC), 1~256 scaler
(PWM01_CLK_DIV_M). Each PWM channel has the secondary frequency division (PWM_PRESCAL_K), clock
source bypass (PWMx_CLK_BYPASS) and clock switch (PWMx_CLK_GATING).
The clock sources have HOSC and APB0. The HOSC comes from the external high-frequency oscillator; the APB0
is APB0 bus clock.
The bypass function of the clock source is that the clock source directly accesses PWM output, the PWM output
waveform is the waveform of the clock controller output. The BYPASS gridlines in the above figure indicate the
bypass function of the clock source, see Figure 9-83 for the details about implement. At last, the output clock
of the clock controller is sent to the PWM logic module.
Taking PWM01 as an example, Figure 9-83 indicates the PWM01 output logic diagram. The logic diagrams of
other PWM pairs are the same as PWM01.
The timer logic module of PWM consists of one 16-bit up-counter (PCNTR) and three 16-bit parameters
(PWM_ENTIRE_CYCLE, PWM_ACT_CYCLE, PWM_COUNTER_START). The PWM_ENTIRE_CYCLE is used to
control the PWM cycle, the PWM_ACT_CYCLE is used to control the duty-cycle, the PWM_COUNTER_START is
used to control the output phase (multi-channel synchronization work requirements).
The PWM_ENTIRE_CYCLE and the PWM_ACT_CYCLE support the cache load, after PWM output is enabled, the
register values of the PWM_ENTIRE_CYCLE and the PWM_ACT_CYCLE can be changed anytime, the changed
value caches into the cache register. When the PCNTR counter outputs a period of PWM waveform, the value
of the cache register can be updated for the PCNTR control. The purpose of the cache load is to avoid the
unstable PWM output waveform with the burred feature when updating the values of the PWM_ENTIRE_CYCLE
and PWM_ACT_CYCLE.
Cycle mode: The PWM outputs the setting PWM waveform continually, that is, the output waveform is a
continuous PWM square wave.
Pulse mode: After setting the PWM_PUL_NUM parameter, the PWM outputs (PWM_PULNUM+1) periods of
PWM waveform, that is, the waveform with several pulses are output.
The period, duty-cycle, and phase of PWM output waveform are decided by the PCNTR, PWM_ENTIRE_CYCLE,
PWM_ACT_CYCLE, and PWM_COUNTER_START. The rules are as follows.
When PCNTR0 > (PPR0. PWM_ENTIRE_CYCLE - PPR0.PWM_ACT_CYCLE), then PWM0 outputs 1 (high level).
When PCNTR0 <= (PPR0. PWM_ENTIRE_CYCLE - PPR0.PWM_ACT_CYCLE), then PWM0 outputs 0 (low level).
The formula of the output period and the duty-cycle for PWM are as follows.
Low level
The formula of the output period and the duty-cycle for PWM are as follows.
Initial state
PWM0
Low level
High level
active state = low
The counter of PCNTR starts from 0 by default, it can output the pulse control of the waveform by setting
PWM_COUNTER_START. The figure is as follows.
PWM_CNTSTART=0
PWM_CNTSTART=1
PWM_CNTSTART=2
PWM_CNTSTART=3
The PWM output supports pulse mode and cycle mode. PWM in pulse mode outputs one pulse waveform, but
PWM in cycle mode outputs continuous waveform. Figure 9-87 shows the PWM output waveform in pulse
mode and cycle mode.
Figure 9-87 PWM0 Output Waveform in Pulse Mode and Cycle Mode
long-period mode
PCR0.PWM_MODE = 0
PWM0_EN = 1 active state
PPR0.PWM_ACT_CYCLE = 3 PPR0.PWM_ACT_CYCLE = 1
Initial state
single-pulse mode
PCR0.PWM_MODE = 1
PWM0_EN = 1 active state active state active state
PCR0.PWM_PUL_START = 1 PCR0.PWM_PUL_START = 1 PCR0.PWM_PUL_START = 1
long-period mode
PCR0.PWM_MODE = 0
PWM0_EN = 1
PPR0.PWM_ACT_CYCLE = 3
Initial state
single-pulse mode
PCR0.PWM_MODE = 1
PWM0_EN = 1 active state active state
PCR0.PWM_PUL_START = 1 PCR0.PWM_PUL_START = 1
Each channel of the PWM module supports the PWM output of pulse mode and cycle mode, the active state
of the PWM output waveform can be programmed to control.
When PCR0[PWM_MODE] is 0, the PWM0 outputs in cycle mode. When PCR0[PWM_MODE] is 1, the PWM0
outputs in pulse mode.
Specifically, in pulse mode, after the PWM0 channel enabled, PCR0[PWM_PUL_START] needs to be set to 1
when the PWM0 needs to output pulse waveform, after completed the output, PCR0[PWM_PUL_START] can
be cleared to 0 by hardware. The next setting 1 can be operated after PCR0[PWM_PUL_START] is cleared.
Every PWM pair supports complementary pair output and PWM pair with dead-time. Figure 9-88 shows the
complementary pair output of PWM01.
Initial state
PWM0
PWM1
PWM0 and PWM1 have the same clock divider, frequency, duty-cycle, and phase
Enable the clock gating of PWM0 and PWM1 at the same time
Enable the waveform output of PWM0 and PWM1 at the same time
Every PWM pair has a programmable dead-time generator. When the dead-time function of the PWM pair
enabled, the PWM01 output waveform is decided by PWM timer logic and DeadZone Generator. Figure 9-89
shows the output waveform.
PWM0
Initial state
PWM1 4 5 6
Initial state
PWM0
Initial state
PWM1
The PWM waveform before the insertion of dead-time indicates a complementary waveform pair of non-
inserted dead-time in Dead Zone Generator 01.
The PWM waveform after the insertion of dead-time indicates a non-complementary PWM waveform pair
inserted dead-time in a complementary waveform pair of Dead Zone Generator 01. The PWM waveform pair
at last outputs to PWM0 pin and PWM1 pin.
For the complementary pair of Dead Zone Generator 01, the principle of inserting dead-time is that to insert
dead-time as soon as the rising edge came. If the high level time for mark② in the above figure is less than
dead-time, then dead-time will override the high level. The setting of dead-time needs to consider the period
and the duty-cycle of the output waveform. The dead-time formula is defined as follows:
Taking PWM Group0 as an example. The same group of PWM channel is selected to work by PGR0.CS; the same
PWM_ENTIRE_CYCLE, PWM_ACT_CYCLE are set by the same clock configuration; the different
PWM_COUNTER_START can output PWM group signals with the same duty-cycle and the different phase.
PWM0_CNTSTART=0
PWM1_CNTSTART=1
PWM2_CNTSTART=2
PWM3_CNTSTART=3
PWM_GROUP0_START=1
CFLR0
CRLR0
CCR0
PPR0 PCNTR0
PCR0.PWM_PRESCAL_K CCR0.CAPINV
CAP0_EN
8-bit PWM TIMER0 0 PWM0 PIN
prescaler LOGIC 1
CFIE0 CCR0.CFLF
CFIS0
CRIE0 CCR0.CRLF
CRIS0
CAP0_EN
PWM01_CLK
CFLR1
CRLR1
CCR1
PPR1 PCNTR1
PCR1.PWM_PRESCAL_K CCR1.CAPINV
CAP1_EN
8-bit PWM TIMER1 0 PWM1 PIN
prescaler LOGIC 1
CFIE1 CCR1.CFLF
CFIS1
CRIE1 CCR1.CRLF
CRIS1
CAP1_EN
Besides the timer logic module of every PWM channel generates PWM output, it can be used to capture the
rising edge and the falling edge of the external clock. Using the PWM0 channel as an example, the PWM0
channel has one CFLR0 and one CRLR0 for capturing up-counter value on the falling edge and rising edge,
respectively. You can calculate the period of the external clock by CFLR0 and CRLR0.
16-bit adding-counter 0 0 0 1 2 3 4 0 1 2 3 0 1 2 3 4 5
reload
external clock reload
CAP0_EN
No reload because of no CRIS0 or CFIS0 set
CRIE0
CFIE0
Set by HW
CRIS0 Clear by SW
Set by HW
CFIS0 Clear by SW
Set by HW Set by HW
Clear by SW Clear by SW
CCR0.CRLF
Set by HW Set by HW
CCR0.CFLF Clear by SW Clear by SW
rising lock
CRLR0 4 falling lock
CFLR0 3
When the capture input function of the PWM0 channel is enabled, the PCNTR of the PWM0 channel starts to
work.
When the timer logic module of PWM0 captures a rising edge, the current value of the up-counter is locked to
CRLR0 and CCR0[CRLF] is set to 1. If CRIE0 is 1, then CRIS0 is set to 1, the PWM0 channel sends interrupt
requests, and the up-counter is loaded to 0 and continues to count. If CRIE0 is 0, the timer logic module of
PWM0 captures a rising edge, CRIS0 cannot be set to 1, the up-counter is not loaded to 0.
When the timer logic module of PWM0 captures one falling edge, the current value of PCNTR is locked to CFLR0
and CCR0[CFLF] is set to 1. If CFIE0 is 1, then CFIS0 is set to 1, the PWM0 channel sends interrupt requests, and
the up-counter is loaded to 0 and continues to count. If CFIE0 is 0, the timer logic module of PWM0 captures a
falling edge, CFIS0 cannot be set to 1, the up-counter is not loaded to 0.
9.10.3.11 Interrupt
The PWM supports an interrupt generation when configuring the PWM channel to PWM output or capturing
input.
For PWM output function, when the controller outputs one period of PWM waveform in cycle mode, the PIS
of the corresponding PWM channel is set to 1; when the controller outputs (PWM_PULNUM+1) periods of
PWM waveform in pulse mode, the PIS of the corresponding PWM channel is set to 1.
NOTE
For capturing input function, when the timer logic module of the capture channel0 captures rising edge, and
CRIE0 is 1, then CRIS0 is set to 1; when the timer logic module of the capture channel0 captures falling edge,
and CFIE0 is 1, then CFIS0 is set to 1.
The following working mode takes PWM01 as an example, other PWM pairs and PWM01 are consistent.
Step 2 PWM clock source select: Set PCCR01[PWM01_CLK_SRC] to select HOSC or APB0 clock.
Step 3 PWM clock divider: Set PCCR01[PWM01_CLK_DIV_M] to select different frequency division
coefficient (1/2/4/8/16/32/64/128/256).
Step 4 PWM clock bypass: Set PCGR[PWM_CLK_SRC_BYPASS_TO_PWM] to 1, output the PWM clock after
the secondary frequency division to the corresponding PWM output pin.
Step 5 PWM internal clock configuration: Set PCR[PWM_PRESCAL_K] to select any frequency division
coefficient from 1 to 256.
NOTE
For the channel of complementary output and group mode, firstly, set the same clock configurations (clock
source selects APB0, clock division configures the same division factor); secondly, open clock gating at the
same time; thirdly, configure PWM parameters; finally, enable PWM output at the same time to ensure each
channel sync.
We suggest that the two channels of the same PWM pair cannot subject to two groups because of they have
the same first level clock division and gating. If must allocate based on this way, the first level of clock division
of the channel used by all groups needs to set to the same coefficient and open gating at the same time.
And the total module needs to be reset when the group mode regroups.
Step 1 PWM mode: Set PCR[PWM_MODE] to select cycle mode or pulse mode, if pulse mode,
PCR[PWM_PUL_NUM] needs to be configured.
Step 2 PWM active level: Set PCR[PWM_ACT_STA] to select a low level or high level.
Step 3 PWM duty-cycle: Configure PPR[PWM_ENTIRE_CYCLE] and PPR[PWM_ACT_CYCLE] after clock gating
is opened.
Step 4 PWM starting/stoping phase: Configure PCNTR[PWM_COUNTER_START] after the clock gating is
enabled and before the PWM is enabled. You can verify whether the configuration was successful by
reading back PCNTR[PWM_COUNTER_STATUS].
Step 5 Enable PWM: Configure PER to select the corresponding PWM enable bit; when selecting pulse mode,
PCR[PWM_PUL_START] needs to be enabled.
Step 2 Capture mode: Configure CCR[CRLF] and CCR[CFLF] to select rising edge capture or falling edge
capture, configure CCR[CAPINV] to select whether the input signal does reverse processing.
9.10.6.3 0x0010 PWM Capture IRQ Enable Register (Default Value: 0x0000_0000)
9.10.6.4 0x0014 PWM Capture IRQ Status Register (Default Value: 0x0000_0000)
9.10.6.10 0x0060 PWM01 Dead Zone Control Register (Default Value: 0x0000_0000)
9.10.6.11 0x0064 PWM23 Dead Zone Control Register (Default Value: 0x0000_0000)
9.10.6.12 0x0068 PWM45 Dead Zone Control Register (Default Value: 0x0000_0000)
9.10.6.13 0x006C PWM67 Dead Zone Control Register (Default Value: 0x0000_0000)
9.10.6.23 0x010C + N*0x20 PWM Pulse Counter Register (Default Value: 0x0000_0000)
9.10.6.24 0x0110 + N*0x20 PWM Capture Control Register (Default Value: 0x0000_0000)
9.10.6.25 0x0114 + N*0x20 PWM Capture Rise Lock Register (Default Value: 0x0000_0000)
9.10.6.26 0x0118 + N*0x20 PWM Capture Fall Lock Register (Default Value: 0x0000_0000)
9.11 LEDC
9.11.1 Overview
LEDC data supports DMA configuration mode and CPU configuration mode
24*32
DMA FIFO
LEDC
Sub-block Description
config register configuration
control LEDC timing control and status control
FIFO 24-bit width x 32 depth
Data_trans Convert input data to the 0 and 1 characters of LED
Package
t1H t1L t0H t0L
led_data_out
…
1 0
data reset
LED data format
wait wait
time0 time1
24bit 24bit ... 24bit 24bit
The RGB mode of LEDC data is configurable. By default, the data is sent in GRB order, and the higher bit is
transmitted first.
G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0
GND GND
L1 L2 LN
GND DO GND DO GND DO DO
C1 C1 C1
VDD- VDD-
5V 5V
C1 is the bypass capacitor of LED light, and its value is usually 100 nF.
1 code T1h
Treset
D0 The 1st 24bit The 2nd 24bit The 3rd 24bit The nth 24bit The 1st 24bit The 2nd 24bit The 3rd 24bit The nth 24bit
D1 The 2nd 24bit The 3rd 24bit The nth 24bit The 2nd 24bit The 3rd 24bit The nth 24bit
D2 The 3rd 24bit The nth 24bit The 3rd 24bit The nth 24bit
When the LED refresh rate is 30 frame/s, LED number supported is (1 s/30-280 us)/((800 ns to 2020 ns)*24)
When the LED refresh rate is 60 frame/s, LED number supported is (1 s/60-280 us)/((800 ns to 2020 ns)*24)
The LEDC supports DMA data transfer mode or CPU data transfer mode. The DMA data transfer mode is set by
LEDC_DMA_EN.
When the valid space of internal FIFO is greater than the setting FIFO free space threshold, the LEDC sends
DMA_REQ to require DMA to transfer data from DRAM to LEDC. The maximum data transfer size in DMA mode
is 16 words. (The internal FIFO level is 32.)
When the valid space of internal FIFO is greater than the setting FIFO free space threshold, the LEDC sends
LEDC_CPUREQ_INT to require CPU to transfer data to LEDC. The transfer data size in CPU mode is controlled
by software. The internal FIFO destination address is 0x06700014. The data width is 32-bit. (The lower 24-bit
is valid.)
CPU mode
DMA mode
Step 4 Configure LEDC_CTRL_REG to enable LEDC_EN, the LEDC will start to output data.
Step 5 When the LEDC interrupt is pulled up, it indicates the configured data has transferred complete, at
this time LED_EN will be set to 0, and the read/write point of LEDC FIFO is cleared to 0.
Step 6 Repeat step1, 2, 3, 4 to re-execute a new round of configuration, enable LEDC_EN, the LEDC will start
new data transfer.
Start
LEDC enable
{LEDC_CTRL_REG}
LED_EN is set to 0
Finish
LEDC_FINSIH_INT
Step 1 When WAITDATA_TIMEOUT_INT appears, it indicates the internal FIFO data request of LEDC cannot
obtain a response, at this time if the default output level is low, then the external LED may think there
was a reset operation and cause LED data to be flushed incorrectly.
Step 2 The LEDC needs to be performed soft_reset operation (LEDC_SOFT_RESET=1); after soft_reset, the
LEDC_EN will be pulled-down automatically, all internal status register and control state machine will
return to the idle state, the LEDC FIFO read & write point is cleared to 0, the LEDC interrupt is cleared.
Step 3 Setting reset_led_en to 1 indicates LEDC can actively send a reset operation to ensure the external
LED lamp in the right state.
Step 4 The software reads the status of reset_led_en, when the status value is 1, it indicates LEDC does not
perform the transmission of LED reset operation; when the status value is 0, the LEDC completes the
transmission of LED reset operation.
Step 5 When LEDC reset operation finishes, the LEDC data and register configuration need to be re-operated
to start re-transmission data operation.
Start
LEDC enable
{LEDC_CTRL_REG}
WAITDATA_TIMEOUT_INT
clear interrupt
LEDC_CTRL_REG
(soft_reset)
LEDC_CTRL_REG
(reset_led_en=1)
Step 1 When FIFO_OVERFLOW_INT appears, it indicates the data configured by software exceeds the LEDC
FIFO space, at this time the redundant data will be lost.
Step 2 The software needs to read data in LEDC_FIFO_DATA_X to confirm the lost data.
Step 4 If the software uses the soft_reset operation, the operation is the same with the timeout abnormal
processing flow.
Start
LEDC enable
{LEDC_CTRL_REG}
FIFO_OVERFLOW_INT
clear interrupt
Software Input
8:6 R/W 0x0 Configuration LEDC Output Mode
Mode
000 GRB
001 GBR
010 RGB
GRB
011 RBG
100 BGR
101 BRG
000 GBR
001 GRB
GBR
010 BGR
011 BRG
9.11.6.2 0x0004 LEDC T0 & T1 Timing Control Register (Default Value: 0x0286_01D3)
9.11.6.3 0x0008 LEDC Data Finish Counter Register (Default Value: 0x1D4C_0000)
9.11.6.4 0x000C LEDC Reset Timing Control Register (Default Value: 0x1D4C_0000)
9.11.6.5 0x0010 LEDC Wait Time 0 Control Register (Default Value: 0x0000_00FF)
9.11.6.10 0x0028 LEDC Wait Time 1 Control Register (Default Value: 0x01FF_FFFF)
9.12 EMAC
9.12.1 Overview
The Ethernet Medium Access Controller (EMAC) enables a host to transmit and receive data over Ethernet in
compliance with the IEEE 802.3-2002 standard. It supports 10/100/1000 Mbit/s external PHY with RMII/RGMII
interface in full-duplex and half-duplex modes. The internal DMA is designed for packet-oriented data transfers
based on a linked list of descriptors.
One 10/100/1000 Mbit/s Ethernet port with reduced gigabit media independent interface (RGMII) and
reduced media independent interface (RMII) interfaces, for connecting the external EPHY
Provides the management data input/output (MDIO) interface for PHY device configuration and
management with configurable clock frequencies
Programmable frame length to support Standard or Jumbo Ethernet frames with sizes up to 16 KB
- Descriptor architecture, allowing large blocks of data transfer with minimum CPU intervention; each
descriptor can transfer up to 4 KB of data
- Comprehensive status reporting for normal operation and transfers with errors
TXFIFO RXFIFO
AHB Slave
xMII
TX+/TX- TX+/TX-
RX+/RX- RX+/RX-
External
EMAC Transformer RJ45
PHY
MDC
MDIO
The internal DMA of EMAC transfers data between host memory and internal RX/TX FIFO by a linked list of
descriptors. Each descriptor consists of four words and contains some necessary information to transfer TX and
RX frames. The following figure shows the descriptor list structure. The address of each descriptor must be 32-
bit aligned.
2nd: Buffer Size 2nd: Buffer Size 2nd: Buffer Size 2nd: Buffer Size
2rd: Buffer Addr 2rd: Buffer Addr 2rd: Buffer Addr 2rd: Buffer Addr
4th: Next Desc 4th: Next Desc 4th: Next Desc 4th: Next Desc
9.12.3.5 TX Descriptor
Bits Description
TX_DESC_CTL
31 When set, the current descriptor can be used by DMA. This bit is cleared by DMA when the
whole frame is transmitted or all data in the buffer of the current descriptor are transmitted.
30:17 Reserved
TX_HEADER_ERR
16
When set, the checksum of the header for the transmitted frame is wrong.
15 Reserved
TX_LENGHT_ERR
14
When set, the length of the transmitted frame is wrong.
13 Reserved
TX_PAYLOAD_ERR
12
When set, the checksum of the payload for the transmitted frame is wrong.
11 Reserved
TX_CRS_ERR
10
When set, the carrier is lost during transmission.
TX_COL_ERR_0
9
When set, the frame is aborted because of a collision after the contention period.
TX_COL_ERR_1
8
When set, the frame is aborted because of too many collisions.
7 Reserved
Bits Description
TX_COL_CNT
6:3
The number of collisions before transmission.
TX_DEFER_ERR
2
When set, the frame is aborted because of too much deferral.
TX_UNDERFLOW_ERR
1
When set, the frame is aborted because of the TX FIFO underflow error.
TX_DEFER
0
When set in Half-Duplex mode, the EMAC defers the frame transmission.
Bits Description
TX_INT_CTL
31 When it is set and the current frame has been transmitted, the TX_INT in Interrupt Status
Register will be set.
LAST_DESC
30
When it is set, the current descriptor is the last one of the current frame.
FIR_DESC
29
When it is set, the current descriptor is the first one of the current frame.
CHECKSUM_CTL
28:27
These bits control to insert checksum in the transmit frame.
CRC_CTL
26
When it is set, the CRC field is not transmitted.
25:11 Reserved
BUF_SIZE
10:0
The size of the buffer specified by the current descriptor.
Bits Description
BUF_ADDR
31:0
The address of the buffer specified by the current descriptor.
Bits Description
NEXT_DESC_ADDR
31:0
The address of the next descriptor. It must be 32-bit aligned.
9.12.3.6 RX Descriptor
Bits Description
RX_DESC_CTL
31 When it is set, the current descriptor can be used by DMA. This bit is cleared by DMA when the
complete frame is received or the buffer of the current descriptor is full.
RX_DAF_FAIL
30
When it is set, the current frame does not pass the DA filter.
RX_FRM_LEN
When LAST_DESC is not set and no error bit is set, this field is the length of received data for
29:16 the current frame.
When LAST_DESC is set, RX_OVERFLOW_ERR and RX_NO_ENOUGH_BUF_ERR are not set, this
field is the length of the received frame.
15 Reserved
RX_NO_ENOUGH_BUF_ERR
14
When it is set, the current frame is clipped because of no enough buffer.
RX_SAF_FAIL
13
When it is set, the current fame does not pass the SA filter.
12 Reserved
RX_OVERFLOW_ERR
11
When it is set, a buffer overflow error occurred and the current frame is wrong.
10 Reserved
FIR_DESC
9
When it is set, the current descriptor is the first descriptor of the current frame.
LAST_DESC
8
When it is set, the current descriptor is the last descriptor of the current frame.
RX_HEADER_ERR
7
When it is set, the checksum of the frame header is wrong.
Bits Description
RX_COL_ERR
6
When it is set, there is a late collision during the reception in half-duplex mode.
5 Reserved
RX_LENGTH_ERR
4
When it is set, the length of the current frame is wrong.
RX_PHY_ERR
3
When it is set, the receive error signal from PHY is asserted during the reception.
2 Reserved
RX_CRC_ERR
1
When it is set, the CRC field of the received frame is wrong.
RX_PAYLOAD_ERR
0
When it is set, the checksum or length of the payload for the received frame is wrong.
Bits Description
RX_INT_CTL
31
When it is set and a frame has been received, the RX_INT will not be set.
30:11 Reserved
BUF_SIZE
10:0
The size of the buffer is specified by the current descriptor.
Bits Description
BUF_ADDR
31:0
The address of the buffer specified by the current descriptor.
Bits Description
NEXT_DESC_ADDR
31:0
The address of the next descriptor. This field must be 32-bit aligned.
In RGMII mode, in addition to the configuration of the transmission clock source, it is generally
necessary to adjust the timing by configuring the transmission clock delay, reception clock delay,
transmission clock reverse, reception clock reverse.
Write 0 to the bit[13] and write 1 to the bit[2] to select the RGMII interface.
If selecting RXCLK as the clock source of RGMII, write 2 to the bit[1:0]; if selecting CLK125M as
the clock source of RGMII, write 1 to the bit[1:0].
Write 0 to the bit[3], write 0 to the bit[4], write 31 to the bit[9:5], and write 7 to the bit[12:10]
to transmit the reception sequence adjustment.
Write 1 to the bit[13] and write 0 to the bit[2] to select the RMII interface.
RMII 0 1 0 0 0 0 0 0
Step 3 Configure EMAC_TX_CTL1 and EMAC_RX_CTL1 to set the configuration of DMA TX and DMA RX.
Step 4 Configure EMAC_INT_EN to set the corresponding interrupts and shield the needless interrupts.
Step 5 Configure EMAC_TX_DMA_LIST and EMAC_RX_DMA_LIST to set the first address of the TX descriptor
and the RX descriptor, respectively.
Step 6 Configure EMAC_TX_CTL0 and EMAC_RX_CTL0 to set the TX and RX parameters. Configure
EMAC_BASIC_CTL0 to set the speed, duplex mode, loopback configuration. (If enabled the auto-
negotiation, the configuration is performed as a result of the negotiation)
Step 8 Configure EMAC_TX_FLOW_CTL and EMAC_RX_CTL0 to set the control mechanism of TX and RX.
9.12.6.7 0x001C EMAC Transmit Flow Control Register (Default Value: 0x0000_0000)
9.12.6.8 0x0020 EMAC Transmit DMA Descriptor List Address Register (Default Value: 0x0000_0000)
9.12.6.11 0x0034 EMAC Receive DMA Descriptor List Address Register (Default Value: 0x0000_0000)
9.12.6.12 0x0038 EMAC Receive Frame Filter Register (Default Value: 0x0000_0000)
9.12.6.13 0x0040 EMAC Receive Hash Table Register0 (Default Value: 0x0000_0000)
9.12.6.14 0x0044 EMAC Receive Hash Table Register1 (Default Value: 0x0000_0000)
9.12.6.17 0x0050 EMAC MAC Address High Register0 (Default Value: 0x0000_FFFF)
9.12.6.18 0x0054 EMAC MAC Address Low Register0 (Default Value: 0xFFFF_FFFF)
9.12.6.19 0x0050+0x08*N EMAC MAC Address High Register N (Default Value: 0x0000_FFFF)
9.12.6.20 0x0054+0x08*N EMAC MAC Address Low Register N (Default Value: 0x0000_0000)
9.12.6.21 0x00B0 EMAC Transmit DMA Status Register (Default Value: 0x0000_0000)
9.12.6.22 0x00B4 EMAC Transmit DMA Current Descriptor Register (Default Value: 0x0000_0000)
9.12.6.23 0x00B8 EMAC Transmit DMA Current Buffer Address Register (Default Value: 0x0000_0000)
9.12.6.24 0x00C0 EMAC Receive DMA Status Register (Default Value: 0x0000_0000)
9.12.6.25 0x00C4 EMAC Receive DMA Current Descriptor Register (Default Value: 0x0000_0000)
9.12.6.26 0x00C8 EMAC Receive DMA Current Buffer Address Register (Default Value: 0x0000_0000)
9.13.1 Overview
The Consumer Infrared receiver (CIR_RX) captures pulse from the IR Receiver module and uses the Run-Length
Code (RLC) to encode the pulse.
Supports interrupt
IRQ
APB
CIR_RX CIR_RX
REG FIFO
LOGIC
SCLK
The CIR_RX samples the input signal on the programmable frequency and records these samples into RX FIFO
when one CIR signal is found on the air. The CIR_RX uses Run-Length Code (RLC) to encode pulse width. The
encoded data is buffered in 64 levels and 8-bit width RX FIFO; the MSB bit is used to record the polarity of the
receiving CIR signal, the rest 7 bits are used for the length of RLC. The maximum length of the RLC is 128. If the
duration of one level (high or low level) is more than 128, another byte is used.
RTC_32K
div4 div2y CIR_RX_CLK SCS SAMPLE_CLK
MUX
clkgate
(1/2/4/8) (/1~32) (/1/64/128/512)
DCXO24M
VCC
CIR_RX
CIR_RX
IR Receiver
GND
ATHR ITHR
When CIR_RX signals satisfy the Active Threshold (ATHR), the CIR receiver can start to capture. In the process,
the signal is ignored if the pulse width of the signal is less than NTHR. When CIR_RX signals satisfy ITHR (Idle
Threshold), the capture process is stopped and the Receiver Packet End interrupt is generated, then the
Receiver Packet End Flag is asserted.
In a capture process, every effective pulse is buffered to FIFO in bytes according to the form of the Run-Length
Code. The MSB bit of a byte is the polarity of pulse, and the rest 7 bits is pulse width by taking Sample Clock as
a basic unit. This is the code form of the RLC-Byte. When the level changes or the pulse width counter overflows,
the RLC-Byte is buffered to FIFO. The CIR_RX module receives the infrared signals transmitted by the infrared
remote control, the software decodes the signals.
Sample Clock
560us 560us
560us 1690us
Logical 0 Logical 1
For NEC protocol, a logical "1" takes 2.25 ms (560 us+1680 us) to transmit, while a logical "0" is only half of
that, being 1.12 ms (560 us+560 us).
For example, if the sample clock is 31.25 kHz, a sample cycle is 32 us, then 18 sample cycles are 560 us. So the
RLC of 560 us low level is 0x12 (b’00010010), the RLC of 560 us high level is 0x92 (b’10010010). Then a logical
“1” takes code 0x12 (b’00010010) and code 0xb5 (b’10110101) to transmit, a logical “0” takes code 0x12 and
code 0x92 to transmit.
When the CIR_RX is in Idle state, if the electrical level of the CIR_RX signal changes (positive jump or negative
jump), and the duration reaches this threshold, then the CIR_RX takes the starting of the signal as a lead code,
and the CIR_RX turns into an active state and starts to capture CIR_RX signals.
ATHR
LSB MSB
9ms 4.5ms Address
If the electrical level of CIR_RX signals has no change, and the duration reaches this threshold, then the CIR_RX
enters into Idle state and ends this capture.
ITHR
LSB MSB
Command
In the capture process, the pulse is ignored if the pulse width is less than the Noise Threshold.
LSB MSB
9ms 4.5ms Address
The APAM is used to fit the type of lead code. If a pulse does not fit the type of lead code, it is not regarded as
a lead code even if the pulse width reaches ATHR.
LSB MSB
9ms 4.5ms Address
When APAM = 11b, a negative pulse is a invalid leading code and will be ignored.
ATHR
LSB
9ms 4.5ms Address
Start
Configure
Pin Multiplex
Enable IRC
RX FIFO No
Available?
Yes
9.13.6.2 0x0010 CIR Receiver Pulse Configure Register (Default Value: 0x0000_0004)
9.13.6.4 0x002C CIR Receiver Interrupt Control Register (Default Value: 0x0000_0000)
9.14.1 Overview
The CIR transmitter (CIR_TX) can transfer arbitrary waves which can be modulated with configurable carrier
waves such as 38 kHz.
cyc_str
tx_str
cyc_fin
tx_act_s
ASP
tx_act_p
idle_cnt_up_p
idle_cnt_up_s
idle_cnt
IR_TX
RFU ACU
Control Signals
wr rd
wdata rdata
tFIFO
wl wl
HOSC Reference
div4 div2y CIR_TX_CLK RCS
MUX
clkgate Clock
(1/2/4/8) (/1~16) (/1/2/4.../512)
PLL_PERI(1X)
The CIR_TX is used to generate a waveform of arbitrary length, arbitrary shape, and no high-speed requirement,
and it can change the data into the high-/low-level sequence of a certain length. Every transmitting data is in
bytes, the Bit[7] of a byte means whether the level of a transmitting wave is high or low, the Bit[6:0] is the
length of this wave. If the current transmitting frequency-division is 1, 0x88 is a high level of 8 cycles, 0x08 is a
low level of 8 cycles. If the current transmitting frequency-division is 4, 0x88 is a high level of 32 cycles, 0x08 is
a low level of 32 cycles.
The CIR_TX has two transmission modes: non-cycle transmission, and cycle transmission.
The non-cycle transmission is to transmit all the data in TX_FIFO until the FIFO is empty.
The cycle transmission is to transmit all the data in TX_FIFO, after the transmission completion, wait for a
certain time to recover the data in TX_FIFO and then send it until a stop signal is detected. The data recovery
in FIFO is implemented by clearing the read pointer.
The CIR remote control contains many protocols designed by different manufacturers. Here to NEC protocol as
an example, the CIR-TX module uses a variable pulse-width modulation technique to encompass the various
formats of infrared encoding for remote-control applications. A message is started by a 9 ms AGC burst, which
is used to set the gain of the earlier CIR receivers. This AGC burst is then followed by a 4.5 ms space, which is
then followed by the address and command.
Bit definition: the logical “1” takes 2.25 ms to transmit, while a logical “0” is only 1.12 ms.
Start
Configure
Pin Multiplex
Enable IRC
Set Transmitter
Threshold
Write TX FIFO
Reach No
Threshold?
Yes
Transmitting Data
Transmitting No
Complete?
Yes
9.14.6.2 0x0004 CIR Transmitter Modulation Control Register (Default Value: 0x0000_009E)
9.14.6.4 0x000C CIR Transmitter Idle Duration Counter High Bit Register (Default Value: 0x0000_0000)
9.14.6.5 0x0010 CIR Transmitter Idle Duration Counter Low Bit Register (Default Value: 0x0000_0000)
9.14.6.6 0x0014 CIR Transmitter Idle Counter High Bit Register (Default Value: 0x0000_0000)
9.14.6.7 0x0018 CIR Transmitter Idle Counter Low Bit Register (Default Value: 0x0000_0000)
9.14.6.8 0x0020 CIR Transmitter FIFO Empty Register (Default Value: 0x0000_0000)
9.14.6.9 0x0024 CIR Transmitter Interrupt Control Register (Default Value: 0x0000_0000)
0 R/W 0x0
TUI_EN
Transmitter FIFO Underrun Interrupt Enable for Non-cyclical
Pulse
0: Disable
1: Enable
9.14.6.10 0x0028 CIR Transmitter FIFO Available Counter Register (Default Value: 0x0000_0080)
9.14.6.13 0x0034 CIR Transmitter DMA Control Register (Default Value: 0x0000_00A5)
9.14.6.14 0x0080 CIR Transmitter FIFO Data Register (Default Value: 0x0000_0000)
Contents
10 Security System ..................................................................................................................................................... 1280
Figures
Figure 10-1 CE Block Diagram ......................................................................................................................................... 1281
Figure 10-3 3DES Encryption and Decryption of a 3-key Operation and a 2-key Operation .......................................... 1283
10 Security System
10.1.1 Overview
The Crypto Engine (CE) module is one encryption/decryption algorithm accelerator. It supports kinds of
symmetric, asymmetric, Hash, and RNG algorithms.
The symmetric algorithm supports data encryption and decryption by following the data encryption standard
(DES), 3DES, or advanced encryption standard (AES) algorithms. It can encrypt or decrypt a large amount of
data effectively.
The Rivest-Shamir-Adleman (RSA) asymmetric algorithm is used for data encryption/decryption and digital
signature verification. It is a public key encryption/decryption algorithm implemented through the modular
exponentiation operation.
The Hash algorithm supports data integrity authentication and digital signature. The hash supports MD5, SHA1,
SHA224, SHA256, SHA384, SHA512, HMAC-SHA1, and HMAC-SHA256 algorithms.
The RNG algorithm can generate true-random numbers and pseudo-random numbers.
The software interface of the CE is simple, only setting interrupt control, task description address, and load tag.
The algorithm control information is written in memory by task descriptor, then the CE automatically reads it
when executing a request. It supports parallel execution of 4 channels and has an internal DMA controller to
transfer data between CE and memory.
Hash algorithm: MD5, SHA1, SHA224, SHA256, SHA384, SHA512, HMAC-SHA1, HMAC-SHA256
Electronic codebook (ECB), cipher block chaining (CBC), counter (CTR), cipher text stealing (CTS), 128-
output feedback (OFB), 1-/8-/64-/128-cipher feedback (CFB) modes for AES algorithm
16-, 32-, 64-, 128-bit wide size for AES CTR mode
ce_ahb
cr
task_handle
ctrl:
aes,des,sha,
RSA
HMAC,prng、
trng...
mux
ss_Mbus
Plaintext Ciphertext
Key Key
encryption decryption
Ciphertext Plaintext
The 3DES algorithm supports both 3-key and 2-key operations. A 2-key operation can be regarded as a
simplified 3-key operation. To be specific, key 3 is represented by key 1 in a 2-key operation. Figure 10-3 shows
the 3DES encryption and decryption operation of a 3-key operation and a 2-key operation.
Figure 10-3 3DES Encryption and Decryption of a 3-key Operation and a 2-key Operation
Plaintext
Ciphertext
DES encryption
Ciphertext
Plaintext
DES decryption
The ECB mode is a confidentiality mode that features, for a given key, the assignment of a fixed ciphertext
block to each plaintext block, analogous to the assignment of code words in a codebook.
In ECB mode, encryption and decryption algorithms are directly applied to the block data. The operation of
each block is independent, so the plaintext encryption and ciphertext decryption can be performed
concurrently.
Plaintext Ciphertext
Key Key
encryption decryption
Ciphertext Plaintext
The CBC mode is a confidentiality mode whose encryption process features the combining of the plaintext
blocks with the previous ciphertext blocks. The CBC mode requires an initialization vector (IV) to combine with
the first plaintext block. The encryption process of each plaintext block is related to the block processing result
of the previous ciphertext blocks, so encryption operations cannot be concurrently performed in CBC mode.
The decryption operation is independent of output plain text of the previous block, so decryption operations
can be performed concurrently.
Initialization
vector Plaintext 1 Plaintext 2 Plaintext n
The CTR mode is a confidentiality mode that features the application of the forward cipher to a set of input
blocks, called counters, to produce a sequence of output blocks that are exclusive-ORed with the plaintext to
produce the ciphertext, and vice versa. All of the counters must be distinct.
The CFB mode is a confidentiality mode that features the feedback of successive ciphertext segments into the
input blocks of the forward cipher to generate output blocks that are exclusive-ORed with the plaintext to
produce the ciphertext, and vice versa. The CFB mode requires an IV as the initial input block, and the forward
cipher operation is applied to the IV to produce the first output block. The first ciphertext segment is produced
by exclusive-ORing the first plaintext segment with the s most significant bits of the first output block. The
value of s is 1 bit, 8 bits, 64 bits, or 128 bits.
The following figure shows the s-bit CFB mode of the AES algorithms.
Initialization
vector
Initialization
vector
The OFB mode is a confidentiality mode that features the iteration of the forward cipher on an IV to generate
a sequence of output blocks that are exclusive-ORed with the plaintext to produce the ciphertext, and vice
versa. If a same key is used, different IVs must be used to ensure operation security.
Initialization
vector
Initialization
vector
The CTS mode is a confidentiality mode that accepts any plaintext input whose bit length is greater than or
equal to the block size but not necessarily a multiple of the block size. Below are the diagrams for CTS
encryption and decryption.
Output block n
Plaintext 1 Plaintext 2
The hash algorithms support MD5, SHA1, SHA224, SHA256, SHA384, SHA512, HMAC-SHA1, and HMAC-SHA256.
All algorithms are iterative, one-way hash functions that can process a message to produce a condensed
representation called a message digest. When a message is received, the message digest can be used to verify
whether the data has changed, that is, to verify its integrity.
The hash algorithm of the CE supports block-aligned total length of the input data (padded by software), that
is, a multiple of 64 bytes. The message length after padding by software is used as the configured data length
for the hash algorithm.
The RSA is a public key encryption/decryption algorithm implemented through the modular exponentiation
operation.
Copyright©Allwinner Technology Co.,Ltd. All Rights Reserved. 1289
Confidential
The ciphertext is obtained as follows: C = ME mod N. The plaintext is obtained as follows: M = CD mod N.
M indicates the plaintext, C indicates the ciphertext, (N, E) indicates the public key, and (N, D) indicates the
private key.
The software makes request through task descriptor, including algorithm type, algorithm mode, key address,
source/destination address and size, and so on. The structure of the task descriptor is as follows.
Task ID
Common Control
Symmetric Control
Asymmetric Control
Key Descriptor
IV Descriptor
Counter Descriptor
Data Length
The data length field in the task descriptor has different meanings
31:0 R/W 0x0 for different algorithms.
For AES-CTS, the data length field indicates byte numbers of source
data, for others indicate word numbers of source data.
In the application, a message may not be stored contiguously in the memory, but divided into multiple
segments. Or a piece of continuously stored messages can be artificially split into multiple pieces as needs.
Then each segment corresponds to a set of the source address and source length in the descriptor. Multiple
segments correspond to groups 0-7 source address/source length in sequence.
Each task supports up to 8 message segments, and the data volume of each message segment supports up to
4 GWord (AES-CTS is 1 GByte). The total amount of all segments in a task (that is a package) supports up to 4
GWord (AES-CTS is 1 GByte). If a message is divided into multiple packages, all others are required to be whole
words; when the last package of AES-CTS is less than one word, 0 needs to be padded, and those less than one
word are counted as one word. The following figure shows the address order structure.
W0 BASE_ADDR
W1 BASE_ADDR + 0x04
W2 BASE_ADDR + 0x08
W3 BASE_ADDR + 0x0C
W4 BASE_ADDR + 0x10
Byte order: low byte first, high byte last. When the data is less than one word, the low byte is filled first. The
following figure shows the byte order structure (blue means it is filled by the message).
B3 B2 B1 B0
Bit order: high bit first, low bit last. When the data is less than one Byte, the high bit is filled first. The following
figure shows the bit order structure.
The length of KEY must be an integer multiple of word, refer to section 10.1.3.15 “Algorithm Length Properties”.
10.1.3.14 Storing IV
For different algorithms, the length of IV is different. But they are integer multiples of word. To keep the byte
order of IV and HASH digest output consistent, the byte order of IV is different from that of the message. For
the multi-packet operation, the first address of the digest output result of the previous HASH can be directly
configured to the first address of the next IV, and the software does not need to do any processing on the
digest.
IV0[31:0] BASE_ADDR
…… ……
IV0[63:32] BASE_ADDR
…… ……
IV7[63:32] BASE_ADDR
The CE module includes error detection for task configuration, data computing error, and authentication invalid.
When the algorithm type in task descriptor is read into the CE module, the CE will check whether this type is
supported through checking algorithm type field in common control. If the type value is out of scope, the CE
will issue interrupt signal and set error state. Each type has certain input and output data size. After getting a
task descriptor, the input size and output size configuration will be checked to avoid size error. If the size
configuration is wrong, the CE will issue interrupt signal and set error state.
Configure task
descriptor
Configure register
Start task
Step 1 The software should configure a task descriptor in memory, including the related fields in the
descriptor. The channel id corresponds to one channel in CE. According to algorithm type, the software
should set the fields in common control, symmetric control, asymmetric control, then provide
key/iv/ctr address and the data length of this task. The source and destination address and size are set
based on the upper application. If there is another task concatenating after this task, then set its
descriptor address at the next descriptor field. For more details for task descriptor, see section 10.1.4.2,
section 10.1.4.3 and section 10.1.4.4.
Step 2 The software should set registers. Configure the first address of the task descriptor structure to CE
Task Descriptor Address Register. Configure the source/destination address to CE Current Source
Address Register/CE Current Destination Address Register.
Step 3 Enable the end interrupt of the corresponding task channel by setting CE Interrupt Control Register.
Step 4 The software reads CE Task Load Register to ensure that the bit0 is 0. If the bit0 is not read out to be
0, wait until it is 0, then configure the bit0 to be 1 to start task.
Common control: Configure Common Control[6:0] to 0x0 to select AES algorithm type.
Symmetric control: According to the corresponding algorithm requirements, configure Symmetric Control
to select the key size, CTR width, CTS last package flag, CFB width, and AES algorithm mode, and so on.
Asymmetric control: The symmetric algorithm does not need to be configured for this field.
Key descriptor: Because the storage of the key requires word alignment, ensure that this descriptor is the
first address of the KEY (word address).
IV descriptor: In the task that requires the IV value, configure the first address of the storage space where
the IV is stored here. Because the storage of the IV requires word alignment, ensure that this descriptor
is the first address of the IV (word address).
Data length: Configure the data length of the corresponding segment. The data length size needs to be
consistent with dst_data_length (destination data length 0 +... + destination data length 7). When the
algorithm is CTS mode, the higher 30-bit of the data length is the word numbers of data volume; when
the data_length[1:0] is 0, the data length is the higher 30-bit, otherwise it is increased by 1. For AES CTS,
the data length indicates the byte numbers of the source data; for other algorithms, it indicates the word
numbers.
Source address: The first address of source data segments. Because the storage of the source data
requires word alignment, ensure that this descriptor is the first address (word address).
Source data length: The data volume of source data segments. The unit is word, and those less than one
word are counted as one word. Note that only the last word of the entire message is allowed to be non-
integer words, and the others must be integer words.
Destination address: The first address of destination data segments. Because the storage of the
destination data requires word alignment, ensure that this descriptor is the first address (word address).
Destination data length: The data volume of destination data segments. The unit is word, and those less
than one word are counted as one word. Note that only the last word of the entire message is allowed to
be non-integer words, and the others must be integer words.
Next descriptor: The first address of the next task descriptor. Because the storage of the descriptor
requires word alignment, ensure that this descriptor is the first address (word address).
Common control
Algorithm type: Configure Common Control[6:0] to select SHA or HMAC algorithm type.
Last HMAC plaintext: If the algorithm type is HMAC, and the task is the last package of the message
or if the message has only one package, then Common Control[15] needs to set to 1.
IV mode: The Common Control[16] (IV MODE) bit is only set to 1 in the following two scenarios,
except that the bit must be configured to 0. (1). When the message is split into multiple packages,
the Common Control[16] bit of other packages needs to be set to 1, except that the bit of the first
package needs to be cleared to 0. (2). In special applications, if you need to customize the IV value to
form the initial value of a certain HASH algorithm, you need to set the Common Control[16] bit of the
first (or only one) package to 1, and the first address of the storage space where the customized IV
value is stored in IV address.
Key descriptor: Because the storage of the key requires word alignment, ensure that this descriptor is the
first address of the KEY (word address).
IV descriptor: In the task that requires the IV value, configure the first address of the storage space where
the IV is stored here. Because the storage of the IV requires word alignment, ensure that this descriptor
is the first address of the IV (word address).
Data length: Configure the data length of the corresponding segment. The data length size needs to be
consistent with dst_data_length (destination data length 0 +... + destination data length 7).
Source address: The first address of source data segments. Because the storage of the source data
requires word alignment, ensure that this descriptor is the first address (word address).
Source data length: The data volume of source data segments. The unit is word, and those less than one
word are counted as one word. Note that only the last word of the entire message is allowed to be non-
integer words, and the others must be integer words.
Destination address: The first address of destination data segments. Because the storage of the
destination data requires word alignment, ensure that this descriptor is the first address (word address).
Destination data length: The data volume of destination data segments. The unit is word, and those less
than one word are counted as one word. Note that only the last word of the entire message is allowed to
be non-integer words, and the others must be integer words.
Next descriptor: The first address of the next task descriptor. Because the storage of the descriptor
requires word alignment, ensure that this descriptor is the first address (word address).
Common control: Configure Common Control[6:0] to 0x20 to select RSA algorithm type.
Key descriptor: Because the storage of the key requires word alignment, ensure that this descriptor is the
first address of the KEY (word address).
Data length: Configure the data length of the corresponding segment. The data length size needs to be
consistent with dst_data_length (destination data length 0 +... + destination data length 7).
Source address: The first address of source data segments. Because the storage of the source data
requires word alignment, ensure that this descriptor is the first address (word address).
Source data length: The data volume of source data segments. The unit is word, and those less than one
word are counted as one word. Note that only the last word of the entire message is allowed to be non-
integer words, and the others must be integer words.
Destination address: The first address of destination data segments. Because the storage of the
destination data requires word alignment, ensure that this descriptor is the first address (word address).
Destination data length: The data volume of destination data segments. The unit is word, and those less
than one word are counted as one word. Note that only the last word of the entire message is allowed to
be non-integer words, and the others must be integer words.
Next descriptor: The first address of the next task descriptor. Because the storage of the descriptor
requires word alignment, ensure that this descriptor is the first address (word address).
10.2 Security ID
The Security ID (SID) is used to program and read keys which include chip ID, thermal sensor, HASH code, and
so on.
CAUTION
Before performing the burning operation, ensure that the power supply of the eFuse power pin is stable.
After the burning operation is completed, cancel the power supply of the eFuse power pin.
Appendix: Glossary
The following table contains acronyms and abbreviations used in this document.
Term Meaning
A
ADC Analog-to-Digital Converter
AE Automatic Exposure
AEC Audio Echo Cancellation
AES Advanced Encryption Standard
AF Automatic Focus
AGC Automatic Gain Control
AHB AMBA High-Speed Bus
ALC Automatic Level Control
ANR Active Noise Reduction
APB Advanced Peripheral Bus
ARM Advanced RISC Machine
AVS Audio Video Synchronization
AWB Automatic White Balance
B
BROM Boot ROM
C
CIR Consumer Infrared
CMOS Complementary Metal-Oxide Semiconductor
CP15 Coprocessor 15
CPU Central Processing Unit
CRC Cyclic Redundancy Check
CSI Camera Serial Interface
CVBS Composite Video Broadcast Signal
D
DDR Double Data Rate
DES Data Encryption Standard
DLL Delay-Locked Loop
DMA Direct Memory Access
DRC Dynamic Range Compression
DVFS Dynamic Voltage and Frequency Scaling
E
ECC Error Correction Code
eFuse Electrical Fuse, A one-time programmable memory
EHCI Enhanced Host Controller Interface
eMMC Embedded Multi-Media Card
ESD Electrostatic Discharge
F
FBGA Fine Pitch Ball Grid Array
Term Meaning
FEL Fireware Exchange Launch
FIFO First In First Out
G
GPIO General Purpose Input Output
I
I2C Inter Integrated Circuit
I2S Inter IC Sound
ISP Image Signal Processor
J
JEDEC Joint Electron Device Engineering Council
JPEG Joint Photographic Experts Group
JTAG Joint Test Action Group
L
LCD Liquid-Crystal Display
LFBGA Low Profile Fine Pitch Ball Grid Array
LSB Least Significant Bit
LVDS Low Voltage Differential Signaling
M
MAC Media Access Control
MIC Microphone
MIPI Mobile Industry Processor Interface
MLC Multi-Level Cell
MMC Multimedia Card
MPEG Motion Pictures Expert Group
MSB Most Significant Bit
N
N/A Not Application
NMI Non Maskable Interrupt
NTSC National Television Standards Committee
NVM Non Volatile Storage Medium
O
OHCI Open Host Controller Interface
OTP One Time Programmable
OWA One Wire Audio
P
PAL Phase Alternating Line
PCM Pulse Code Modulation
PHY Physical Layer Controller
PID Packet Identifier
PLIC Platform-Level Interrupt Controller
PLL Phase-Locked Loop
POR Power-On Reset
PRCM Power Reset Clock Management
Term Meaning
PWM Pulse Width Modulation
R
R Read only/non-Write
RGB Read Green Blue
RGMII Reduced Gigabit Media Independent Interface
RMII Reduced Media Independent Interface
ROM Read Only Memory
RSA Rivest-Shamir-Adleman
RTC Real Time Clock
S
SAR Successive Approximation Register
SD Secure Digital
SDIO Secure Digital Input Output
SDK Software Development Kit
SDRAM Synchronous Dynamic Random Access Memory
SDXC Secure Digital Extended Capacity
SLC Single-Level Cell
SoC System on Chip
SPI Serial Peripheral Interface
SRAM Static Random Access Memory
T
TDES Triple Data Encryption Standard
TWI Two Wire Interface
U
UART Universal Asynchronous Receiver Transmitter
UDF Undefined
Transmitter
USB DRD Universal Serial Bus Dual Role Device
UTMI USB2.0 Transceiver Macrocell Interface
This documentation is the original work and copyrighted property of Allwinner Technology Co.,Ltd (“Allwinner”). No part
of this document may be reproduced, modify, publish or transmitted in any form or by any means without prior written
consent of Allwinner.
Allwinner and the Allwinner logo (incomplete enumeration) are trademarks of Allwinner Technology Co.,Ltd. All other
trademarks, trade names, product or service names mentioned in this document are the property of their respective
owners.
The purchased products, services and features are stipulated by the contract made between Allwinner Technology
Co.,Ltd (“Allwinner”) and the customer. All or part of the products, services and features described in this document may
not be within the purchase scope or the usage scope. Please read the terms and conditions of the contract and relevant
instructions carefully before using, and follow the instructions in this documentation strictly. Allwinner assumes no
responsibility for the consequences of improper use (including but not limited to overvoltage, overclock, or excessive
temperature).
The information in this document is provided just as a reference or typical applications, and is subject to change without
notice. Every effort has been made in the preparation of this document to ensure accuracy of the contents. Allwinner is
not responsible for any damage (including but not limited to indirect, incidental or special loss) or any infringement of
third party rights arising from the use of this document. All statements, information, and recommendations in this
document do not constitute a warranty or commitment of any kind, express or implied.
No license is granted by Allwinner herein express or implied or otherwise to any patent or intellectual property of
Allwinner. Third party licences may be required to implement the solution/product. Customers shall be solely responsible
to obtain all appropriately required third party licences. Allwinner shall not be liable for any licence fee or royalty due in
respect of any required third party licence. Allwinner shall have no warranty, indemnity or other obligations with respect
to third party licences.