(EN) MG32F02A128 064 DataSheet V1.20
(EN) MG32F02A128 064 DataSheet V1.20
(EN) MG32F02A128 064 DataSheet V1.20
MG32F02A128
MG32F02A064
Data Sheet
Version: 1.20
Features
CPU Core
ARM 32-bit Cortex-M0 CPU
Operation frequency up to 48MHz
Built-in one NVIC for 32 external interrupt inputs with 4-level priority
Built-in one 24-bit system tick timer
Built-in one single-cycle 32-bit multiplier
Built-in one SWD serial wire debugger with 2 watch points and 4 breakpoints
Flash Memory
Built-in embedded max. 128K bytes flash memory for application code
Support ICP (In-circuit program) for ISP boot code update through SWD interface
Support ISP (In-system program) for application code update
▬ Support programmable ISP flash memory size for ISP boot code
Support IAP (In-application program) for application data update
▬ Support programmable IAP flash memory size
SRAM Memory
Built-in embedded max. 16K bytes SRAM
▬ Support private 2K bytes for DMA and 14K bytes for software to improve access performance
Power
Built-in one embedded regulator for core logic power
Built-in brown-out detectors
▬ BOD0 detect 1.4V
▬ BOD1 detect by selected level 4.2V/3.7V/2.4V/2.0V
▬ BOD2 detect 1.7V
Built-in a power management controller with power-down and wakeup control
Support three power operation modes
▬ ON(Normal) mode and SLEEP , STOP power down modes
Support wake-up from SLEEP/STOP modes via multiple sources
Reset
Built-in embedded POR (power-on reset) circuit
Built-in one reset source controller
▬ Programmable chip cold reset and warm reset for reset source
▬ Independent software reset control for internal modules
Provide multiple reset source
▬ POR/BOD/External reset pin input/Software force reset
▬ IWDT/WWDT/ADC/Analog Comparator
▬ Illegal address error reset/Flash access protect error reset
▬ Missing clock detect (MCD) reset
Clock
Built-in embedded ILRCO (internal low frequency RC oscillator) by 32KHz
Built-in embedded IHRCO (internal high frequency RC oscillator)
▬ Trimmed to 11.059 or 12MHz ±1% at +25℃
Built-in embedded PLL clock output for system clock
Built-in embedded XOSC oscillator with MCD for external 32KHz and 4 ~ 25MHz Xtal
Support external clock input up to 36MHz
Built-in a clock source controller with independent clock enable control for modules
Support internal XOSC oscillator and internal ILRCO/IHRCO clock output
DMA (Direct Memory Access)
1. General Description
The MG32F02A is a single-chip 32-bit microcontroller based on a high performance Core ARM 32-bit
Cortex™-M0 CPU with embedded Nested Vectored Interrupt Controller (NVIC).
The MG32F02A has up to 128K bytes of embedded main flash memory for code and data, programmable
memory size of embedded system flash memory for boot load code and 64 bytes of embedded option-byte
flash memory for chip configuration. The all flash memory can be programmed either in serial writer mode (ICP,
In-Circuit-Programming). Also, the main flash memory can be programmed in ISP (In-System Programming)
mode or SRAM (Boot on SRAM) mode. ICP and ISP allow the user to download new code without removing
the microcontroller from the actual end product; IAP means that the device can write non-volatile data in the
flash memory while the application program is running. There needs no external high voltage for programming
due to its built-in charge-pumping circuitry.
The MG32F02A retains all features of the ARM 32-bit Cortex™-M0 with 16K bytes of SRAM, 5 I/O ports,
32 external interrupts source with 4-level interrupt controller and seven 8/16-bits timer/counters. In addition, the
MG32F02A/U has a System Tick Timer, two Watchdog Timers, three Advance timer modules with IC/OC, four
Basic timer modules for universal using, on-chip crystal oscillator for 32.768 KHz to 25MHz, two high precision
internal oscillators IHRCO for 11.059/12MHz and ILRCO for 32 KHz, one 12-bit ADC with one temperature
sensor, two programmable threshold comparators and one 12-bit voltage mode DAC.
Also, the MG32F02A support multiple and flexible communicate interface for production application. It
provides alternate function pins those are including of GPIO, I2C, SPI, UART, Timer with IC/PWM, ADC,
Analog Comparator, DAC, EMB, NCO, CCL and SWD(on chip debug). It has maximum 73 GPIO pins and
provides programmable IO type - quasi-bidirectional , push-pull output , open-drain output , input only(Hi-z) with
optional pull-high. In addition, it is built-in internal de-bounce circuit to deglitch noise for worse signals.
One direct memory access (DMA) controller is used to improve data transfer between peripherals and
memory and memory to memory. The data can be transfer by DMA controller and does not cost any CPU time.
One external memory bus (EMB) controller is used to access external SRAM, NOR/NAND flash or 8080
interface LCD display panel. It supports multiple address bus and data bus multiplex modes. Also it supports
synchronous or asynchronous timing with programmable cycle time for external devices.
For power management and reset control, the MG32F02A is built-in a power supervisor including of a Low
Voltage Detector(LVD), three Brown-out Detectors(BOD0/BOD1/BOD2), a Power-On Reset(POR) , a Low-
voltage Reset(LVR). The MG32F02A has multiple power-down modes to reduce the current consumption:
Sleep mode and Stop mode.
In the Sleep mode the CPU is frozen while the peripherals and the interrupt system are still operating. In
the Stop mode the RAM and SFRs’ value are saved and all other functions are inoperative; most importantly, in
the Sleep mode the chip can be waked up by many interrupt or reset sources(POR/LVR/BOD0/BOD1/BOD2).
2. Order Information
Please contact the megawin sales for available options (memory size, package …) and more information
about this device.
Figure 2-1. Part Numbering
MG 32 F 0 2A xxx yy zz
megawin
Device family
32 = 32-bit MCU
Application family
F = Mainstream
MCU Series
0 = ARM Cortex-M0
Device Series
2A = General Series
Package type
AD = LQFP
Pin count
80 = 80 pins
64 = 64 pins
48 = 48 pins
3. Block Diagram
3.1. System Function Block
The following diagram is showing the system function block for application.
Key pad
ADC
Analog Signal
General Purpose
I/O Control
AP/Boot Power
SRAM
Memory Flash Control
Control
MAn External Hardware Reset
Memory Bus
GPL
MADn Option Control
Bridge PLL
PCx Port C I/O GPIO OSC
PDx Port D I/O IHRCO
ILRCO
PEx Port E I/O
IO Bus IO Bus
POR/LVR
XIN
OSC I2Cx TM0x
XOUT
IO Bus
TM1x
Temperature TM2x
Sensor
AMUX
CMPx_In
CMP_Cn COMPx APB
4. Pin Description
PD15
PD14
PD13
PD12
PD11
PD10
VDD
VSS
VR0
PD9
PD8
PD7
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
ADC7/PA7 1 60 PD6
ADC8/PA8 2 59 PD5
ADC9/PA9 3 58 PD4
ADC10/PA10 4 57 PD3
ADC11/PA11 5 56 PD2
ADC12/PA12 6 55 PD1
ADC13/PA13 7 54 PD0
ADC14/PA14 8 53 PE15
ADC15/PA15 9 52 PE14
NSS/PB0 10 MG32F02 51 PE13
MISO/PB1
SCK/PB2
11
12
LQFP80 50
49
PE12
VSS1
MOSI/PB3 13 48 PC14/XOUT
PE0 14 47 PC13/XIN
PE1 15 46 PC12
PE2 16 45 PC11/SDA1
PE3 17 44 PC10/SCL1
SD3/PB4 18 43 PC9/RXD1
SD2/PB5 19 42 PC8/TXD1
PB6 20 41 PC7
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
RSTN/PC6
TXD0/PB8
RXD0/PB9
ICKO/PC0
PB7
PB12
VDD2
PB13
PB14
VSS2
PB15
PE8
PE9
PC1
PC2
PC3
SCL0/PB10
SDA0/PB11
SWDIO/PC5
SWCLK/PC4
2020_0515
Pin Group
GPIOA GPIOB
GPIOC GPIOD
GPIOE
Power/Ground Others
PA6/ADC6
PA5/ADC5
PA4/ADC4
PA3/ADC3
PA2/ADC2
PA1/ADC1
PA0/ADC0
VREF+
PD11
PD10
VDD
VSS
VR0
PD9
PD8
PD7
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
ADC7/PA7 1 48 PD6
ADC8/PA8 2 47 PD5
ADC9/PA9 3 46 PD4
ADC10/PA10 4 45 PD3
ADC11/PA11 5 44 PD2
ADC12/PA12 6 43 PD1
ADC13/PA13 7 42 PD0
ADC14/PA14 8 MG32F02 41 VSS1
ADC15/PA15
NSS/PB0
9
10
LQFP64 40
39
PC14/XOUT
PC13/XIN
MISO/PB1 11 38 PC12
SCK/PB2 12 37 PC11/SDA1
MOSI/PB3 13 36 PC10/SCL1
SD3/PB4 14 35 PC9/RXD1
SD2/PB5 15 34 PC8/TXD1
PB6 16 33 PC7
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
RSTN/PC6
TXD0/PB8
RXD0/PB9
ICKO/PC0
PB7
PC1
PC2
PC3
PB12
PB13
PB14
PB15
SCL0/PB10
SDA0/PB11
SWDIO/PC5
SWCLK/PC4
2020_0515
Pin Group
GPIOA GPIOB
GPIOC GPIOD
Power/Ground Others
PA3/ADC3
PA2/ADC2
PA1/ADC1
PA0/ADC0
VREF+
PD10
VDD
VSS
VR0
PD9
PD8
PD7
48
47
46
45
44
43
42
41
40
39
38
37
ADC8/PA8 1 36 PD3
ADC9/PA9 2 35 PD2
ADC10/PA10 3 34 PD1
ADC11/PA11 4 33 PD0
ADC12/PA12 5 32 PC14/XOUT
ADC13/PA13 6
MG32F02 31 PC13/XIN
ADC14/PA14 7 30 PC12
ADC15/PA15 8
LQFP48 29 PC11/SDA1
NSS/PB0 9 28 PC10/SCL1
MISO/PB1 10 27 PC9/RXD1
SCK/PB2 11 26 PC8/TXD1
MOSI/PB3 12 25 PC6/RSTN
13
14
15
16
17
18
19
20
21
22
23
24
TXD0/PB8
RXD0/PB9
ICKO/PC0
PB13
PB14
PC1
PC2
PC3
SCL0/PB10
SDA0/PB11
SWDIO/PC5
SWCLK/PC4
2020_0515
Pin Group
GPIOA GPIOB
GPIOC GPIOD
Power/Ground Others
LQFP64
LQFP48
Type
Value
PA8 GPA8 DMA_TRG0 I2C0_SCL URT2_BRO SDT_I0 TM20_IC0 SPI0_NSS MA8 MAD0 TM36_OC0H URT4_TX
PA9 GPA9 DMA_TRG1 I2C1_SCL URT2_TMO TM20_IC1 SPI0_MISO MA9 MAD1 TM36_OC1H URT5_TX
PA1
GPA10 TM36_BK0 SPI0_D2 I2C0_SDA URT2_CTS SDT_I1 TM26_IC0 SPI0_CLK MA10 MAD2 TM36_OC2H URT4_RX
0
PA1
GPA11 DAC_TRG0 SPI0_D3 I2C1_SDA URT2_RTS TM26_IC1 SPI0_MOSI MA11 MAD3 TM36_OC3H URT5_RX
1
PA1
GPA12 URT1_BRO TM10_ETR TM36_IC0 SPI0_D5 MA12 MAD4 TM26_OC00 URT6_TX
2
PA1 TM10_TRG
GPA13 CPU_TXEV URT0_BRO URT1_TMO TM36_IC1 SPI0_D6 MA13 MAD5 TM26_OC10 URT6_RX
3 O
PA1
GPA14 CPU_RXEV OBM_I0 URT0_TMO URT1_CTS TM16_ETR TM36_IC2 SPI0_D7 MA14 MAD6 TM26_OC0H URT7_TX
4
PA1 TM16_TRG
GPA15 CPU_NMI OBM_I1 URT0_DE URT1_RTS TM36_IC3 SPI0_D4 MA15 MAD7 TM26_OC1H URT7_RX
5 O
URT1_NS
PB0 GPB0 I2C1_SCL SPI0_NSS TM01_ETR TM00_CKO TM16_ETR TM26_IC0 TM36_ETR MA15 URT6_TX
S
TM16_TRG TM36_TRG
PB1 GPB1 I2C1_SDA SPI0_MISO TM01_TRGO TM10_CKO TM26_IC1 URT1_RX URT6_RX
O O
URT1_CL
PB2 GPB2 ADC0_TRG SPI0_CLK TM01_CKO URT2_TX TM16_CKO TM26_OC0H I2C0_SDA URT0_TX URT7_TX
K
PB3 GPB3 ADC0_OUT SPI0_MOSI NCO_P0 URT2_RX TM36_CKO TM26_OC1H I2C0_SCL URT1_TX URT0_RX URT7_RX
PB4 GPB4 TM01_CKO SPI0_D3 TM26_TRGO URT2_CLK TM20_IC0 TM36_IC0 MALE MAD8
PB5 GPB5 TM16_CKO SPI0_D2 TM26_ETR URT2_NSS TM20_IC1 TM36_IC1 MOE MAD9
PB6 GPB6 CPU_RXEV SPI0_NSSI URT0_BRO URT2_CTS TM20_ETR TM36_IC2 MWE MAD10 URT2_TX
TM20_TRG
PB7 GPB7 CPU_TXEV URT0_TMO URT2_RTS TM36_IC3 MCE MALE2 URT2_RX
O
PB8 GPB8 CMP0_P0 RTC_OUT URT0_TX URT2_BRO TM20_OC01 TM36_OC01 SPI0_D3 MAD0 SDT_P0 OBM_P0 URT4_TX
PB9 GPB9 CMP1_P0 RTC_TS URT0_RX URT2_TMO TM20_OC02 TM36_OC02 SPI0_D2 MAD1 MAD8 OBM_P1 URT4_RX
PB1
GPB10 I2C0_SCL URT0_NSS URT2_DE TM20_OC11 TM36_OC11 URT1_TX MAD2 MAD1 SPI0_NSSI
0
PB1
GPB11 I2C0_SDA URT0_DE IR_OUT TM20_OC12 TM36_OC12 URT1_RX MAD3 MAD9 DMA_TRG0 URT0_CLK
1
PB1
GPB12 DMA_TRG0 NCO_P0 URT1_CLK MAD4 MAD2 URT5_TX
2
PB1 TM20_TRG
GPB14 DMA_TRG0 TM00_TRGO URT0_RTS TM36_BK0 URT0_NSS MAD6 MAD3 CCL_P1 URT4_TX
4 O
PB1
GPB15 IR_OUT NCO_CK0 URT1_NSS MAD7 MAD11 URT5_RX
5
PC0 GPC0 ICKO TM00_CKO URT0_CLK URT2_CLK TM20_OC00 TM36_OC00 I2C0_SCL MCLK MWE URT0_TX URT5_TX
PC1 GPC1 ADC0_TRG TM01_CKO TM36_IC0 URT1_CLK TM20_OC0N TM36_OC0N I2C0_SDA MAD8 MAD4 URT0_RX URT5_RX
PC2 GPC2 ADC0_OUT TM10_CKO OBM_P0 URT2_CLK TM20_OC10 TM36_OC10 SDT_I0 MAD9 MAD12
PC3 GPC3 OBM_P1 TM16_CKO URT0_CLK URT1_CLK TM20_OC1N TM36_OC1N SDT_I1 MAD10 MAD5
PC6 GPC6 RSTN RTC_TS URT0_NSS URT1_NSS TM20_ETR TM26_ETR MBW1 MALE
TM36_TRG
PC7 GPC7 ADC0_TRG RTC_OUT URT0_DE URT1_NSS MBW0 MCE
O
PC8 GPC8 ADC0_OUT I2C0_SCL URT0_BRO URT1_TX TM20_OC0H TM36_OC0H TM36_OC0N MAD11 MAD13 CCL_P0 URT6_TX
PC9 GPC9 CMP0_P0 I2C0_SDA URT0_TMO URT1_RX TM20_OC1H TM36_OC1H TM36_OC1N MAD12 MAD6 CCL_P1 URT6_RX
PC1
GPC10 CMP1_P0 I2C1_SCL URT0_TX URT2_TX URT1_TX TM36_OC2H TM36_OC2N MAD13 MAD14 URT7_TX
0
PC1
GPC11 I2C1_SDA URT0_RX URT2_RX URT1_RX TM36_OC3H TM26_OC01 MAD14 MAD7 URT7_RX
1
PC1 TM10_TRG
GPC12 IR_OUT DAC_TRG0 URT1_DE TM36_OC3 TM26_OC02 MAD15 SDT_P0
2 O
PC1 TM20_IC
GPC13 XIN URT1_NSS URT0_CTS URT2_RX TM10_ETR TM26_ETR TM36_OC00 SDT_I0 URT6_RX
3 0
PD0 GPD0 OBM_I0 TM10_CKO URT0_CLK TM26_OC1N TM20_CKO TM36_OC2 SPI0_NSS MA0 MCLK URT2_NSS
PD1 GPD1 OBM_I1 TM16_CKO URT0_CLK NCO_CK0 TM26_CKO TM36_OC2N SPI0_CLK MA1 URT2_CLK
PD2 GPD2 TM00_CKO URT1_CLK TM26_OC00 TM20_CKO TM36_CKO SPI0_MOSI MA2 MAD4 URT2_TX
TM36_TRG
PD3 GPD3 TM01_CKO URT1_CLK SPI0_MISO TM26_CKO SPI0_D3 MA3 MAD7 URT2_RX
O
PD4 GPD4 TM00_TRGO TM01_TRGO URT1_TX TM26_OC00 SPI0_D2 MA4 MAD6 URT2_TX
PD5 GPD5 TM00_ETR I2C0_SCL URT1_RX TM26_OC01 SPI0_MISO MA5 MAD5 URT2_RX
PD6 GPD6 CPU_NMI I2C0_SDA URT1_NSS SPI0_NSSI TM26_OC02 SPI0_NSS MA6 SDT_P0 URT2_NSS
PD7 GPD7 TM00_CKO TM01_ETR URT1_DE SPI0_MISO TM26_OC0N SPI0_D4 MA7 MAD0 TM36_IC0
PD8 GPD8 CPU_TXEV TM01_TRGO URT1_RTS SPI0_D2 TM26_OC10 SPI0_D7 MA8 MAD3 TM36_IC1 SPI0_CLK
PD9 GPD9 CPU_RXEV TM00_TRGO URT1_CTS SPI0_NSSI TM26_OC11 SPI0_D6 MA9 MAD2 TM36_IC2 SPI0_NSS
PD1 SPI0_MOS
GPD10 CPU_NMI TM00_ETR URT1_BRO RTC_OUT TM26_OC12 SPI0_D5 MA10 MAD1 TM36_IC3
0 I
PD1
GPD11 CPU_NMI DMA_TRG1 URT1_TMO SPI0_D3 TM26_OC1N SPI0_NSS MA11 MWE
1
PD1
GPD12 CMP0_P0 TM10_CKO OBM_P0 TM00_CKO SPI0_CLK TM20_OC0H TM26_OC0H MA12 MALE2
2
PD1
GPD13 CMP1_P0 TM10_TRGO OBM_P1 TM00_TRGO NCO_CK0 TM20_OC1H TM26_OC1H MA13 MCE
3
PD1
GPD14 TM10_ETR DAC_TRG0 TM00_ETR TM20_IC0 TM26_IC0 MA14 MOE CCL_P0 URT5_TX
4
PE0 GPE0 OBM_I0 URT0_TX DAC_TRG0 SPI0_NSS TM20_OC00 TM26_OC00 MALE MAD8 URT4_TX
PE1 GPE1 OBM_I1 URT0_RX DMA_TRG1 SPI0_MISO TM20_OC01 TM26_OC01 MOE MAD9 TM36_OC0H URT4_RX
PE2 GPE2 OBM_P0 I2C1_SCL URT1_TX NCO_P0 SPI0_CLK TM20_OC02 TM26_OC02 MWE MAD10 TM36_OC1H URT5_TX
PE3 GPE3 OBM_P1 I2C1_SDA URT1_RX NCO_CK0 SPI0_MOSI TM20_OC0N TM26_OC0N MCE MALE2 URT5_RX
PE8 GPE8 CPU_TXEV OBM_I0 URT2_TX SDT_I0 TM36_CKO TM20_CKO TM26_CKO MAD11 URT4_TX
TM16_TRG
PE13 GPE13 ADC0_OUT TM01_TRGO TM20_OC11 TM26_OC11 MBW1 TM36_OC2H URT6_RX
O
PE14 GPE14 RTC_OUT I2C1_SCL TM01_ETR TM16_ETR TM20_OC12 TM26_OC12 MALE2 CCL_P0 TM36_OC3H URT7_TX
PE15 GPE15 RTC_TS I2C1_SDA TM36_BK0 TM36_ETR TM20_OC1N TM26_OC1N MALE CCL_P1 URT7_RX
Pin AFS=0 AFS=1 AFS=2 AFS=3 AFS=4 AFS=5 AFS=6 AFS=7 AFS=8 AFS=9 AFS=10 AFS=11
5. Memory Map
5.1. Memory Organization
There are up to 16K bytes of SRAM built in the chip. The chip has up to 128K bytes of embedded main
flash memory for code and data, programmable memory size of embedded system flash memory for boot load
code and 64 bytes of embedded option-byte (OB) flash memory for chip configuration. Others, there are many
module independent hardware control registers and locate at the memory space of AHB/APB devices.
User can configure the whole flash to store for his Application Program (AP) code, In-System-Program
(ISP) code and In-Application-Program (IAP) memory. User can adjust the size for the three flash memories.
The following diagram is showing the memory organization map. There are separated eight memory blocks
and the memory size is 512M-byte for each block. The block is signed “XN” which is not able to execute code.
CPU Memory
Figure 5-1. Memory Organization Map Map
Block/Type CPU Address Linear Logical Address Size
Device
System Device 512MB
XN Space
Private Peripheral Bus
0xE000 0000
External
1GB
Device External Device
Space
XN
0xA000 0000
1GB
External RAM External RAM Space
0x6000 0000
Peripheral 512MB
AHB/APB Devices
XN Space
0x4000 0000
512MB
SRAM
Space
0x2000 0000 SRAM
0x1FF4 0000
OB2 Flash
0x1FF3 0000
OB1 Flash
0x1FF2 0000
OB0 Flash
0x1FF1 0000
0x1FF0 0000 ISPD Flash
AP Flash
0x1800 0000
Relocated Boot
Memory Space
0x0000 0000 (no physical memory)
3 External 0x6000 0000 0x7FFF FFFF 512MB Reserved External memory (SRAM, Flash)
RAM
2 Peripheral XN 0x4000 0000 0x5FFF FFFF 512MB APB/AHB APB/AHB modules
0x3000 0200 0x3FFF FFFF 256MB Reserved
0x3000 0000 0x3000 01FF 512B Reserved
1 SRAM 0x2000 4000 0x2FFF FFFF 256MB Reserved
0x2000 3800 0x2000 3FFF 2KB SRAM Upper 2K-byte suggestion for DMA
0x2000 0000 0x2000 37FF 14KB SRAM
0x1FF3 0200 0x1FFF FFFF 832KB Reserved
0x1FF3 0040 0x1FF3 01FF 448B
OB Flash-2
0x1FF3 0000 0x1FF3 003F 64B Hardware Option byte-2 (64-byte)
0x1FF2 0200 0x1FF2 FFFF 64KB Reserved
0x1FF2 0050 0x1FF2 01FF 432B
0x1FF2 0040 0x1FF2 004F 16B OB Flash-1 Unique ID (16-byte)
0x1FF2 0000 0x1FF2 003F 64B Hardware Option byte-1 (64-byte)
0x1FF1 0200 0x1FF1 FFFF 64KB Reserved
0x1FF1 0040 0x1FF1 01FF 448B
OB Flash-0
0x1FF1 0000 0x1FF1 003F 64B Hardware Option byte-0 (64-byte)
0x1FF0 0200 0x1FF0 FFFF 64KB Reserved
0 Code 0x1FF0 0000 0x1FF0 01FF 512B ISPD Flash ISP data flash
0x1C02 0000 0x1FEF FFFF 63MB Reserved
Boot Flash memory (configurable
0x1C00 0000 0x1C01 FFFF 128KB ISP Flash
size)
0x1A02 0000 0x1BFF FFFF 32MB Reserved
Data Flash memory (configurable
0x1A00 0000 0x1A01 FFFF 128KB IAP Flash
size)
0x1802 0000 0x19FF FFFF 32MB Reserved
Application Flash memory
0x1800 0000 0x1801 FFFF 128KB AP Flash
(configurable size by chip option)
0x0002 0000 0x17FF FFFF 384MB Reserved
Relocated memory Interrupt Vector
0x0000 0000 0x0001 FFFF 128KB
space 0x0000 00C0~0x0000 0000
XN : eXecute Never , 1 Block = 512MB
Relocated memory space : Main flash memory, Boot flash memory or SRAM depending on BOOT configuration
6. Functional Description
6.1. CPU Core
6.1.1. Introduction
The chip is embedded a CPU core of Cortex™-M0 processor. The processor is a configurable, multistage,
32-bit RISC processor. It has an AMBA AHB-Lite interface and includes an NVIC component. It also has
optional DAP hardware debug functionality.
The processor can execute Thumb code and is compatible with other Cortex-M profile processor. The
profile supports two modes -Thread mode and Handler mode. Handler mode is entered as a result of an
exception. An exception return can only be issued in Handler mode. Thread mode is entered on Reset, and can
be entered as a result of an exception return.
6.1.2. CPU Features
ARM 32-bit Cortex-M0 CPU
Operation frequency up to 48MHz
Built-in one NVIC for 32 external interrupt inputs with 4-level priority
Built-in one 24-bit system tick timer
Built-in one single-cycle 32-bit multiplier
Built-in one SWD serial wire debugger with 2 watch points and 4 breakpoint
The ARMv6-M Thumb® instruction set
6.1.3. ARM Cortex-M0 Processor
The following diagram is showing the block of ARM Cortex-M0 Processor.
CK_AHB
Clock Gating Control
Cortex-M0 Components
Clock Domain
Cortex-M0 Processor
FCLK SCLK HCLK DCLK SWCLKTCK
DAP
Debug
Nested
Interrupts SWD
Vectored Cortex-M0 Breakpoint
and SWCLKTCK
Interrupt Processor
Controller Core Watchpoint
(NVIC) Unit
6.8. GPIO
6.8.1. Introduction
The chip has following I/O ports: PA[15:0], PB[15:0], PC[14:0], PD[15:0], PE[0:3][8:9][12:15]. Support
maximum 73 GPIO pins for LQFP80 package. RSTN pin is an alternated function pin on PC6. If select external
crystal oscillator as system clock input, PC13 and PC14 are configured to XIN and XOUT. The exact number of
I/O pins available depends upon the package types.
The chip has built in several IO mode control (PA/PB/PC/PD/PE) modules for each GPIO port. These
modules are used for GPIO pin IO mode control, alternated function selection, driver strength setting, input
inverse selection, pull-high enable, deglitch filter setting and high speed enable. Also one IO Port access
control (IOP) module is built-in to control the input and output state of GPIO mode for all GPIO ports.
6.8.2. Features
Support general purpose IO pins for application
▬ Maximum 73 GPIO pins for LQFP80 package
▬ Maximum 59 GPIO pins for LQFP64 package
▬ Maximum 44 GPIO pins for LQFP48 package
Provide selectable IO modes by pin independent
▬ Push-Pull output
▬ Quasi bidirectional
▬ Open-drain output
▬ Input only with high impedance
▬ Analog IO
Flexible pin alternate function selection
Support programmable drive strength by pin independent
Support IO deglitch filter by pin independent
6.9. Interrupt
6.9.1. Introduction
After reset, the CPU begins execution from the location of reset interrupt vector (0x00000004) addressing,
where should be the starting of the user’s application code. To service the interrupts, the interrupt service
locations (called interrupt vectors) should be located in the address 0x000000BF~0x00000000.
The chip is built-in ARM cortex M0 CPU and is embedded a NVIC (Nested Vectored Interrupt Controller) for
32 external interrupt inputs with 4-level priority. Also builds in an EXIC (External Interrupt Controller) module
and connects to NVIC.
6.9.2. Interrupt Features
Built-in one NVIC for 32 external interrupt inputs with 4-level priority
Built-in one EXIC (external interrupt controller) for NVIC connection
▬ Independent high/low level and rising/falling edge trigger selection
Built-in one WIC (wakeup interrupt controller) for wakeup event control
All GPIO pins can be configured as interrupt source and key pad input
▬ Support port OR logic for interrupt function
▬ Support port AND logic for KBI function
Support external pins for CPU NMI/RXEV/TXEV function
▬ Configurable pin for CPU NMI input function
▬ Configurable pin for CPU RXEV input function
▬ Configurable pin for CPU TXEV output function
6.9.3. Interrupt Structure
12~13 - Reserved -
Interrupt Priority
The priority scheme for servicing the interrupts has four interrupt levels. The priority bits in CPU registers,
IPR0-7, SHPR2 and SHPR3, determine the priority level of each interrupt.
The interrupt priority registers provide an 8-bit priority field for each interrupt and each register holds four
priority fields. The processor implements only bits [7:6] of each field, bits [5:0] read as zero and ignore writes.
Higher-priority interrupt will be not interrupted by lower-priority interrupt request. If two interrupt requests of
different priority levels are received simultaneously, the request of higher priority is serviced. If interrupt
requests of the same priority level are received simultaneously, an internal polling sequence determine which
request is serviced. The table of “interrupt sources” shows the internal polling sequence in the same priority
level and the interrupt vector address. The lower exception number gets the higher priority.
6.9.4. Nested Vectored Interrupt Controller
The Cortex-M0 processor integrates a configurable Nested Vectored Interrupt Controller (NVIC) that
supports low latency interrupt processing and includes a non-mask interrupt (NMI). The NVIC provides a zero-
jitter interrupt option and four interrupt priority levels.
6.12. APX
6.12.1. Introduction
The chip builds in one APX module for the extended function control of APB devices.
6.12.2. Features
Support two sets of CCL(Configurable Custom Logic)
6.16. DAC
6.16.1. Introduction
The chip builds in one DAC module which embeds one 12-bit voltage mode DAC (digital-to-analog
converter) and digital logic for input code control. The digital-to-analog conversion can be performed and start
trigger by data register written, events (external pin input or internal events). The DAC can output a full-scale
voltage from 0.2 volt to VDD-0.2 volt under the conversion rate up to 1MHz when DAC output buffer is on.
6.16.2. Features
One 12-bit voltage DAC
▬ Maximum conversion rate is 1MHz
▬ Analog output to ADC internal channel
Conversion start trigger by register written, external pin and internal events
Build in internal output buffer
Data alignment for input code left/right justify
▬ Configurable code width : 12/10/8-bit
Output data are buffered with DMA capability
6.16.3. DAC Control Block
The DAC control block consists of a 1Msps/12-bit voltage mode DAC, reference voltage circuit, a DAC data
code register, a DAC conversion output register (DAC_DOR0) and DAC conversion trigger start control block.
The DAC output is programmable to full-scale output voltage from 0.2 volt to VDD-0.2 volt with DAC output
buffer on. The voltage DAC output resistive load is minimum 7.5Kohm with DAC output buffer on.
6.17. IWDT
6.17.1. Introduction
The chip has one independent Watch-dog timer to use as a recovery method in situations where the CPU
may be subjected to software upset. It will trigger system reset when the counter reaches a given timeout value.
6.17.2. Features
8-bit down counter with 12-bit prescaler and clocked by its own CK_ILRCO
Operating capability in SLEEP and STOP modes
Selectable reset or interrupt when the counter underflow
Support two early wakeup comparators with interrupt
Support register key-protected and reset-locked functions
6.17.3. IWDT Control
The IWDT watch-dog timer consists of a 12-bit prescaler and an 8-bit timer. When the watch-dog timer is
6.18. WWDT
6.18.1. Introduction
The system window watchdog is used to detect the occurrence of a software fault which causes the
application program abnormal. The watchdog circuit generates a system reset when the counter reaches a
given timeout value.
The WWDT has a configurable time-window that can be programmed to detect abnormally late or early
application behavior.
6.18.2. Features
10-bit counter with 1 or 256 divider , 1/2/4~/128 divider
Configurable time-window to detect abnormally late or early application behavior
Selectable reset or interrupt when the counter is underflow or reloaded outside the window
Support warning interrupt
Support register key-protected and reset-locked functions
6.18.3. WWDT Control
The WWDT watch-dog timer consists of one /1 or /256 clock prescaler, one 7-bit clock divider and one 10-
bit timer. When the watch-dog timer is enabled, software should always reset the timer before the timer is
timeout. When the watch-dog timer is reset, the timer will reload the value to restart counting.
When the firmware is out of control, which may miss to reset the timer and the timer timeout will be coming.
It makes the WWDT generating a reset event and sends it to Reset Source Controller (RST) to do as the warm
reset events or cold reset events. If the firmware reset the timer and the counter value is over the threshold
value of window compare threshold in the same time, it also makes the WWDT generating a reset event.
6.19. RTC
6.19.1. Introduction
The real-time clock is an independent 32-bit timer. The RTC provides a time clock with programmable
alarm interrupt. User can use as a calendar with software programmable alarm seconds, minutes, hours, day,
and date.
The RTC provides a wakeup flag to perform auto wakeup from power down mode with interrupt.
6.19.2. Features
Built-in 32-bit counter with selectable clock source
Support alarm function and time-stamp function
▬ Support alarm function with 32-bit programmable compare register
Support wakeup from Stop mode
Support periodic timer tick interrupt or wakeup
Support register key-protected and reset-locked functions
6.20. Timer
6.20.1. Introduction
The chip has seven Timer/Counter modules: TM00, TM01, TM10, TM16, TM20, TM26 and TM36. All of
them can be configured as timers or event counters.
TM0x has an 8-bit timer/counter with 8-bit prescaler. TM1x has a 16-bit timer/counter with 16-bit prescaler.
TM2x has a 16-bit timer/counter with 16-bit prescaler and embeds two input capture/output compare channels.
TM36 has a 16-bit timer/counter with 16-bit prescaler and embeds four input capture/output compare channels.
6.20.2. Features
Provide seven timers/counters : TM00,TM01,TM10,TM16,TM20,TM26,TM36
Timer module common functions
▬ Selectable Full-counter , Cascade , Separate modes
▬ Multiple internal and external signals as timer clock source or trigger source
▬ Internal timer events output to pin or other modules as input trigger event
▬ Support timer reset , trigger start and clock gating for trigger source function
▬ Timer overflow as clock output to external pin output
▬ Programmable counter auto-stop mode
▬ Main counter support up/down control (TM16/TM26/TM36 only)
▬ 2nd counter support up/down control (Separate mode)
Provide TM36 timer module
▬ 32-bit timer/counter
▬ 4 CCP (input Capture/output Compare/PWM) channels
▬ 3 CCP channels with OCN (complementary output compare)
▬ PWM function with center-align, dead time control and break control
▬ Support OC comparator split to two separated comparators mode
▬ QEI(Quadrature Encoder Interface) support
▬ One IC and three OC with DMA capability
▬ Extra repetition counter for auto-stop mode
Provide TM2x timer modules
▬ 32-bit timer/counter
▬ 2 CCP (input Capture/output Compare/PWM) channels
▬ 2 CCP channels with OCN (complementary output compare)
▬ PWM function with edge-align
▬ Support OC comparator split to two separated comparators mode
▬ QEI(Quadrature Encoder Interface) support (TM26 only)
6.21. I2C
6.21.1. Introduction
The I2C interface is a two-wire, bi-directional serial bus. It is ideally suited for typical microcontroller
applications. The I2C protocol allows the systems designer to interconnect up to 128 different devices using
only two bi-directional bus lines, one for clock (SCL) and one for data (SDA). The I2C bus provides control of
SDA, SCL generation and synchronization, arbitration logic, and START/STOP control and generation. The
only external hardware needed to implement this bus is a single pull-up resistor for each of the I2C bus lines.
All devices connected to the bus have individual addresses, and mechanisms for resolving bus contention are
inherent in the I2C protocol.
The I2C module builds in the shadow buffer and data register to improve transmit and receive communication
performance.
6.21.2. Features
Provide two identical I2c modules : I2C0 , I2C1
Support master and slave mode
Support programmable clock rate control and clock rate up to 1 MHz
Support programmable high/low period control for master mode
Support clock stretching for slave mode
Support general call function
Support multi-master processing capability
Support both Byte mode and Buffer mode flow control
Support Byte mode bus event code for simplex firmware control
Support Buffer mode 4-byte data buffer and 32-bit data register for high speed communication
Received and transmitted data are buffered with DMA capability
Support slave address hardware detection wakeup from STOP mode
Support SMBus timeout detection
6.22. UART
6.22.1. Introduction
The UART module support full-duplex transmission, meaning it can transmit and receive simultaneously.
The module builds in the shadow buffer and data register by transmit and receive independently to improve
transmit and receive communication performance. It can commence reception of a second byte before a
previously received byte has been read from the register. However, if the first byte still hasn’t been read by the
time reception of the second byte is complete, one of the bytes will be lost.
The module can operate in multiple modes: asynchronous communication, synchronous communication,
SPI master, SmartCard, LIN, multi-processor mode. The asynchronous communication operates as a full-
duplex Universal Asynchronous Receiver and Transmitter (UART), which can transmit and receive
simultaneously and at different baud rates.
6.22.2. Features
Provide seven UART modules : URT0~2, URT4~7
UART module common functions
▬ Provide precise UART baud-rate control by programmable oversampling rate
▬ Support baud rate up to 6 Mbit/s
▬ Programmable data word length - 7 or 8 bits
▬ Hardware parity checking and parity generation
▬ Programmable 4~32 oversampling rate
▬ Swappable TX/RX pin configuration
▬ Separate signal polarity control for transmission and reception
Provide URT0/1/2 advanced UART module
▬ Support UART, Synchronous, SPI master/slave, SmartCard, LIN, Multi-processor modes
▬ Selectable MSB or LSB first data order
▬ Configurable stop bits - 0.5,1,1.5 or 2 stop bits
▬ Support a timeout timer for Idle/RX/Break/Calibration timeout detection
▬ Support 4-byte data buffer and 32-bit data register for high speed communication
▬ Support auto baud-rate detection and calibration
▬ Support multiprocessor communication for master and slave mode - Idle-Line , Address-Bit
▬ Support low speed UART-like frame format IrDA
▬ Support transceiver hardware flow control by CTS/RTS signals only
▬ Provide driver enable signal to activate the transmission for bidirectional communication
▬ Support transmission-error hardware detection and auto resent control for Smart-card application
▬ Support receiving parity error hardware detection and auto retry control for Smart-card
application
▬ Received and transmitted data are buffered with DMA capability
Provide URT4/5/6/7 basic UART modules
▬ Support TX/RX independent 8-bit data register for simplex firmware control
▬ Configurable stop bits - 1 or 2 stop bits
6.23. SPI
6.23.1. Introduction
The chip provides a high-speed serial peripheral interface (SPI). SPI is a full-duplex, high-speed and
synchronous communication bus with two operation modes: Master mode and Slave mode. The SPI clock rate
can be up to 22 MHz for Master mode and up to 16 MHz for Slave mode under a 48MHz APB clock.
The SPI module builds in the shadow buffer and data register by transmit and receive independently to
improve transmit and receive communication performance.
6.23.2. Features
Support master and slave mode
▬ Support full duplex , half duplex or simplex communication mode
▬ Support data communication without NSS(slave select signal)
▬ Support master data input sampling delay half of SPI clock
▬ Support configurable idle state for SPI master standard mode data output
▬ Support asynchronous clock mode for SPI slave standard mode
Support programmable clock rate control
Selectable 4~32-bit frame size
▬ Support 4-byte data buffer and 32-bit data register for high speed communication
Received and transmitted data are buffered with DMA capability
Support multi-master processing capability
Selectable clock polarity and phase
7. Application Notes
7.1. Power Supply Circuit
To have the chip work with power supply varying from 1.8V to 5.5V, adding some external decoupling and
bypass capacitors is necessary on VDD/VSS power pins, as shown in following figure. Also the same
application suggestion on VDD2/VSS2 power pins for LQFP80 package. The VR0 pin is the embedded LDO
voltage output as internal core logic power supply. It needs to place one 0.1uF capacitor and one 4.7uF
capacitor to be closed the pin.
The following figure is showing the power supply suggestion circuit.
(close chi p)
10uF 0.1uF 0.1uF 4.7uF
Ground
Power VSS
(optional) Power
VDD2
(close chip)
10uF 0.1uF
VSS1
Ground
VSS2
MCU
<Note> : 1. VSS1 pin is implemented on LQFP64/80 packages only.
2. VDD2/VSS2 pins are implemented on LQFP80 packages only.
RSTN RSTN
4.7uF CExT
VSS VSS
C1
(Internal
Crystal
Rf feedback
resister)
CX IN
C2
(close chip) OSC_IN
C1/C2 = Xtal CL*2 – (1~5 pF)
R1 : drive limit resister Megawin MCU
The following table lists the suggested C1 & C2 value for the different capacitor load (CL) crystal
application.
C11 and C22 are symmetric, we can get C11 = C22 = 21 ~ 23 pF.
Then C1 = C11 - CXOUT = 19pF ~ 22.1pF 20pF
C2 = C22 - CXIN = 18.6pF ~ 20.8pF 20pF
C11 and C22 are symmetric, we can get C11 = C22 = 36 ~ 38 pF.
Then C1 = C11 - CXOUT = 34pF ~ 37.1pF 36pF
C2 = C22 - CXIN = 33.6pF ~ 35.8pF 36pF
MCU
(R/C decide by
application)
MCU
8. Electrical Characteristics
8.1. Parameter Glossary
Table 8-1. Parameter Glossary
BOD0 V V V V V V V V V V V
BOD1 V V V V
SLEEP
Normal Normal Normal Normal Low Power
Mode (*3)
ADC0 CK_APB CK_APB CK_APB CK_APB
IWDT CK_ILRCO CK_ILRCO CK_ILRCO CK_ILRCO CK_ILRCO CK_ILRCO CK_ILRCO CK_ILRCO CK_ILRCO CK_ILRCO
TM00 CK_APB CK_APB CK_APB CK_APB CK_APB CK_APB CK_APB CK_APB CK_APB
TM01 CK_APB
TM16 CK_APB
TM20 CK_APB
TM26 CK_APB
I2C1 CK_APB
URT1 CK_APB
URT2 CK_APB
SPI0 CK_APB
IO Pins all Push-Pull Low IO Toggle all Push-Pull Low all Push-Pull Low
Note: (*1) [CPU Code]
dhrystone: CPU runs "Dhrystone" benchmarks code.
normal code: Set CK_APB and CK_AHB frequency by table. The module clock divider can be /4, /8 or others.
heavy code: 1. Set CK_APB and CK_AHB frequency by table. The module clock set the highest frequency (module clock DIV=/2).
2. Let the module operates as busy as possible and fills full data through the buffer. (EX: transfer 4 bytes for one transaction)
(*2) Normal: PW_LDO_ON=0, Low Power: PW_LDO_STP=1
(*3) Normal: PW_WKSLP_MDS=0, Low Power: PW_WKSLP_MDS=1
UART
Figure 8-1. UART Timing Electrical
Waveform AC Timing
URTx_CLK
tQVXH
tXHQX
URTx_TX Start 0 1 6 7 Stop
URTx_RX 0 1 5 6 7
tXHDV tXHDX
SPIx_CLK
(SPIx_CPOL=0)
(Clock Idle Low)
(SPIx_CPOL=1)
(Clock Idle High)
(SPIx_CPHA=0) tMOH
(Leading Edge Sample)
Hi-Z
SPIx_MOSI
(Master output)
SPIx_MISO
(Master Input)
tMIS tMIH
SPIx_NSS
SPIx_CLK
(SPIx_CPOL=0)
(Clock Idle Low)
(SPIx_CPOL=1)
(Clock Idle High)
SPIx_MOSI
(Master output)
Hi-Z
SPIx_MISO
(Master Input)
tf tSU:DAT tHD:DAT tr
70% 70% 70%
tVD:DAT tVD:ACK
70% 70% 70% 70%
9. Package Dimension
9.1. LQFP-80
LQFP-80
LQFP-80
Figure 9-1. LQFP-80 (10mm(10mm X 10mm)
X 10mm) ~ AD80~ AD80
Unit mm inch
Symbols Min. Nom. Max. Min. Nom. Max.
A --- --- 1.60 --- --- 0.062
A1 0.05 --- 0.15 0.001 --- 0.005
A2 1.35 1.40 1.45 0.053 0.055 0.057
b 0.13 0.18 0.23 0.005 0.007 0.009
c 0.09 --- 0.20 0.003 --- 0.007
D 12.00 BSC 0.472 BSC
D1 10.00 BSC 0.393 BSC
E 12.00 BSC 0.472 BSC
E1 10.00 BSC 0.393 BSC
e 0.40 BSC 0.015 BSC
L 0.45 0.60 0.75 0.018 0.024 0.030
L1 1.00 REF 0.039 REF
ɵ 0˚ 3.5˚ 7˚ 0˚ 3.5˚ 7˚
Unit mm inch
Symbols Min. Nom. Max. Min. Nom. Max.
A --- --- 1.60 --- --- 0.062
A1 0.05 --- 0.15 0.001 --- 0.005
A2 1.35 1.40 1.45 0.053 0.055 0.057
b 0.13 0.18 0.23 0.005 0.007 0.009
c 0.09 --- 0.20 0.003 --- 0.007
D 9.00 BSC 0.354 BSC
D1 7.00 BSC 0.275 BSC
e 0.40 BSC 0.015 BSC
E 9.00 BSC 0.354 BSC
E1 7.00 BSC 0.275 BSC
L 0.45 0.60 0.75 0.018 0.024 0.030
L1 1.00 REF 0.039 REF
ɵ 0˚ 3.5˚ 7˚ 0˚ 3.5˚ 7˚
Unit mm inch
Symbols Min. Nom. Max. Min. Nom. Max.
A --- --- 1.60 --- --- 0.062
A1 0.05 --- 0.15 0.001 --- 0.005
A2 1.35 1.40 1.45 0.053 0.055 0.057
b 0.17 0.22 0.27 0.006 0.008 0.010
c 0.09 --- 0.20 0.003 --- 0.007
D 9.00 BSC 0.354 BSC
D1 7.00 BSC 0.275 BSC
E 9.00 BSC 0.354 BSC
E1 7.00 BSC 0.275 BSC
e 0.50 BSC 0.019 BSC
L 0.45 0.60 0.75 0.018 0.024 0.030
L1 1.00 REF 0.039 REF
ɵ 0˚ 3.5˚ 7˚ 0˚ 3.5˚ 7˚
3 Add the table of “Table 8-4. Current Measurement Condition Level Definition Table”. 8.3
Update the “TR1~TR7” and “TF1~TF7” parameters in the table of “Table 8-5. IO
4 8.4
Characteristics”.
Update the “VR0” and “VDROP” parameters in the table of “Table 8-10. LDO
5 8.9
Characteristics”.
Revision V0.72 (2021_1215) Chapter
5 Correct the wrong word “Slop” to “Slope” in the table of “Table 8-3. DC Characteristics”. 8.3
Change “Cycle-to-Cycle Jitter” to “Period Jitter” in the table of “Table 8-6. PLL
6 8.6
Characteristics”.
Update the “SPI Clock Frequency” parameters of slave mode in the table of “Table 8-17.
7 8.17
SPI Characteristics”.
Update the diagram of package dimension for each package in Package Dimension
8 9
chapter.
Revision V0.71 (2021_0623) Chapter
2 Update the description of the section of “6.15.3. CMP Control Block”. 6.15.3
Update the Conditions description of “Current Consumption” in the table of “Table 8-3. DC
3 8.3
Characteristics”.
5 Add the ISLP3/ISLP4/tWK_SLP1 parameters in the table of “Table 8-3. DC Characteristics”. 8.3
6 Merge the IDAC/IBUF parameters in the table of “Table 8-15. DAC Characteristics”. 8.15
1 Add ‘Wakeup Time’ characteristics in the table of “Table 8-3. DC Characteristics”. 8.3
1 Preliminary version
11. Disclaimers
Herein, megawin stands for “Megawin Technology Co., Ltd.”
Life Support — This product is not designed for use in medical, life-saving or life-sustaining applications, or
systems where malfunction of this product can reasonably be expected to result in personal injury. Customers using
or selling this product for use in such applications do so at their own risk and agree to fully indemnify Megawin for
any damages resulting from such improper use or sale.
Right to Make Changes — Megawin reserves the right to make changes in the products - including circuits,
standard cells, and/or software - described or contained herein in order to improve design and/or performance. When
the product is in mass production, relevant changes will be communicated via an Engineering Change Notification
(ECN).