Presentation is loading. Please wait.

Presentation is loading. Please wait.

單晶片實作應用 ARM Cortex-M0 Introduction

Similar presentations


Presentation on theme: "單晶片實作應用 ARM Cortex-M0 Introduction"— Presentation transcript:

1 單晶片實作應用 ARM Cortex-M0 Introduction
樹德科技大學資訊工程系 吳鴻志副教授

2 簡介 主題:讓學生了解單晶片介紹 單元名稱:微處理單片介紹-1 學習時數:3小時 適用對象:資訊工程系大三學生

3 綱要 Block Diagram ISP/ICP System Memory Map Power Management
Reset Source Clock Control Interrupt CMSIS

4 NUC100 Series Functional Block Diagram
AHB Lite Interface Peripherals Analog Macro Clock Source APROM LDROM

5 M051 Series Functional Block Diagram

6 ARM Cortex-M0 Functional Block Diagram
4 Break Point 2 Watchpoint

7 NuMicro Family System Introduction
The NUC 100 series IC embed Cortex –M0 core running up to 50 MHz 32K/64K/128K bytes embedded flash by part No Configurable data flash address and size for 128kB system, fixed 4kB data flash for the 32kB and 64kB system 4kB flash for ISP loader 4K/8K/16K embedded SARM The M051 series IC embed Cortex-M0 core 8KB/16KB/32KB/64KB Flash memory for program memory (APROM) 4KB Flash memory for data memory (DataFlash) 4KB Flash memory for loader (LDROM) 4KB SRAM for internal scratch-pad RAM (SRAM) Support ISP (In System Programming) by USB or UART Support 2 wire ICP ( In Circuit Programming) update from ICE interface Support fast parallel programming mode by external writer 2 wire SWD ICE interface Wide operating voltage ranges from 2.5V to 5.5V

8 ICP (In Circuit Programming)
NuMicro ICP AP USB Nu-Link NuMicro Family SWD I/F

9 ISP (In System Programming)
NuMicro ISPAP RS232 Cable USB Cable UART I/F USB I/F Address M0-CPU Update Code ROMCODE LDROM APROM Nuvoton ISP LDROM firmware code Boot From LDROM USB interface only supports NUC120/NUC140 series

10 NuMicro ISP vs ICP Difference
Item ISP ICP PC AP Software NuMicro ISP Programmer NuMicro ICP Programming Tools.exe Extra Hardware No NuLink CPU Run Code CPU runs on the LDROM What Region Can Be Updated APROM DataFlash Config LDROM Interface USB or UART SWD Support Off-Line Programming Yes

11 System Memory Map System Peripheral SRAM Code 0xE000_EFFF
Application Program Memory (APROM) 0x0000_0000 0x0001_FFFF Reserved ISP Loader Program Memory (LDROM) 0x0010_0000 0x0010_0FFF APB peripherals 0x4000_0000 0x401F_FFFF AHB peripherals 0x5000_0000 0x501F_FFFF Cortex M0 System Register 0xE000_E000 0xE000_EFFF RAM 0x2000_0000 0x2000_3FFF Code SRAM Peripheral System

12 Power Management Normal Run Mode Sleep Mode (IDLE Mode)
Flexible system clock source selection All peripherals clock can be turned off individually. Sleep Mode (IDLE Mode) CPU halt, peripheral is probably under running which depends on your application Deep Sleep Mode (Power Down Mode) CPU & peripheral are all halt

13 Power Management – Cont.
Sleep mode UNLOCKREG(); SCB->SCR = 4; SYSCLK->PWRCON.WINT_EN = 0; SYSCLK->PWRCON.PD_WAIT_CPU = 1; SYSCLK->PWRCON.PWR_DOWN = 0; LOCKREG(); __WFI(); Deep Sleep mode SYSCLK->PWRCON.PWR_DOWN = 1;

14 System Reset Hardware Reset Software Reset The Power-On Reset
/RESET pin Reset Watchdog Time Out Reset Low Voltage Detected Reset Brown-Out-Detected Reset Software Reset CPU_RST To write 1 to the CPU_RST( IPRSTC1[1],”IP Reset Source Register”) register Just only reset CPU & flash controller CHIP_RST To write 1 to CHIP_RST( IPRSTC1[0], IP Reset Source Register) register To reset the whole chip like “Power-on reset” MCU_RST Write 1 to the SYSRESETREQ (AIRCR[2], Application Interrupt & Reset Control Register”) To reset the whole chip “RSTSRC” register identify chip’s reset source from last operation

15 RSTRC( System Reset Source Register)
Address R/W Description Reset Value RSTSRC 0x5000_0004 System Reset Source Register 0x0000_00xx These bits are cleared by writing 1 to itself 7 6 5 4 3 2 1 RSTS_CPU Reserved RSTS_MCU RSTS_BOD RSTS_LVR RSTS_WDG RSTS_PAD RSTS_POR CPU_RST /RESET Pin Reset MCU_RST Watchdog Reset Brown Out Reset LVR Reset

16 System Reset Resource Table
Reset Status Reset Source 7 6 5 4 3 2 1 RSTS_CPU Reserved RSTS_MCU RSTS_BOD RSTS_LVR RSTS_WDG RSTS_PAD RSTS_POR Power-On Reset x Reset Pin Reset Watchdog Time Out Reset X LVR Reset Brown-Out Reset Cortex-M0 MCU CHIP_RST CPU_RST

17 Peripheral IP Reset Every peripheral has corresponded reset register
“IPRSTC1” & “IPRSTC2” register had defined the corresponded peripheral asynchronous reset signal

18 NUC100 Clock Generator External Crystal Internal RC

19 M051 Clock Generator External Crystal Internal RC

20 NuMicro System Clock Source
NUC 100 series System Clock Source M051 series System Clock Source

21 SysTick Clock Source NUC100 Series System Clock Source
For the other peripherals IP, they also have multi-clock source to set.

22 NuMicro NVIC NVIC (Nested Vectored Interrupt Controller)
An integrated part of the Cortex-M0 processor It supports 32 peripheral interrupts input it supports NMI( Nonmaskable Interrupt) input It supports “Tail Chaining” & “Late Arrival” Interrupt handler follows the CMSIS coding rule

23 C ISR Function Call Name
In “startup_NUC1xx.s” vector table address save peripherals ISR function address

24 ISR Handler

25 System Peripheral Interrupt Map(16~32)
Vector Number Interrupt Number (Bit in Interrupt Registers) Interrupt Name Source IP Interrupt description 0 ~ 15 - System exceptions 16 BOD_OUT Brown-Out Brownout low voltage detected interrupt 17 1 WDT_INT WDT Watch Dog Timer interrupt 18 2 EINT0 GPIO External signal interrupt from PB.14 pin 19 3 EINT1 External signal interrupt from PB.15 pin 20 4 GPAB_INT External signal interrupt from PA[15:0] / PB[13:0] 21 5 GPCDE_INT External interrupt from PC[15:0]/PD[15:0]/PE[15:0] 22 6 PWMA_INT PWM0~3 PWM0, PWM1, PWM2 and PWM3 interrupt 23 7 PWMB_INT PWM4~7 PWM4, PWM5, PWM6 and PWM7 interrupt 24 8 TMR0_INT TMR0 Timer 0 interrupt 25 9 TMR1_INT TMR1 Timer 1 interrupt 26 10 TMR2_INT TMR2 Timer 2 interrupt 27 11 TMR3_INT TMR3 Timer 3 interrupt 28 12 UART0_INT UART0 UART0 interrupt 29 13 UART1_INT UART1 UART1 interrupt 30 14 SPI0_INT SPI0 SPI0 interrupt 31 15 SPI1_INT SPI1 SPI1 interrupt 32 SPI2_INT SPI2 SPI2 interrupt

26 System Peripheral Interrupt Map(33~47)
Vector Number Interrupt Number (Bit in Interrupt Registers) Interrupt Name Source IP Interrupt description 33 17 SPI3_INT SPI3 SPI3 interrupt 34 18 I2C0_INT I2C0 I2C0 interrupt 35 19 I2C1_INT I2C1 I2C1 interrupt 36 20 CAN0_INT CAN0 CAN0 interrupt 37 21 Reserved 38 22 39 23 USB_INT USBD USB FS Device interrupt 40 24 PS2_INT PS2 PS2 interrupt 41 25 ACMP_INT ACMP Analog Comparator-0 or Comaprator-1 interrupt 42 26 PDMA_INT PDMA PDMA interrupt 43 27 I2S_INT I2S I2S interrupt 44 28 PWRWU_INT CLKC Clock controller interrupt for chip wake up from power-down state 45 29 ADC_INT ADC0/1 ADC interrupt 46 30 47 31 RTC_INT RTC Real time clock interrupt

27 CMSIS Cortex Microcontroller Software Interface Standard
ARM& Tool vendor (Keil, IAR..) Structure Core Peripheral Access Layer (CPAL) Middleware Access Layer (MWAL) (ARM is current in development) Device Peripheral Access Layer (DPAL) Provide definitions for all device peripherals

28 CMSIS directory structure
CMSIS changes.htm CMSIS debug support.htm License.doc CMSIS_V1P30 CM0 CoreSupport core_cm0.c core_cm0.h ARMCM0.h system_ARMCM0.c system_ARMCM0.h DeviceSupport ARM ARMCM0 startup arm startup_ARMCM0.s gcc iar main_ARMCM0.c startup_ARMCM0.s system_ARMCM0.c Example arm ARMCM0 CM3 iar Sourcery G++Lite Documentation CMSIS_Core.htm

29 CMSIS coding rule ANSI standard types defined in the ANSI C header file <stdint.h> are used For each exception/interrupt An exception/interrupt handler rule exception: the postfix _Handler interrupts: the postfix _IRQHandler A # define of the interrupt number with postfix _IRQn A default exception/interrupt handler (weak definition) that contains an endless loop

30 What CMSIS Files Do You Need For NUC100 Series?
NUC1xx.h(device.h) Interrupt Number Definition Device Peripheral Access Layer Provides definitions for all device peripherals. It contains all data structures and the address mapping for the device specific peripherals To define the peripherals for the actual device. It can use several other include files to define the peripherals of the actual devices startup_NUC1xx.s(startup_device.s) Cortex-M0 startup code and the complete Interrupt Vector Table system_NUC1xx.c(system_device.c) core_cm0.h core_cm0.c ARM offer 2 files IC Vendor Offer 3files

31 NUC100 Interrupt Number Definition
typedef enum IRQn { /****** Cortex-M0 Processor Exceptions Numbers ***************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /*!< 3 Cortex-M0 Hard Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M0 SV Call Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M0 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M0 System Tick Interrupt */ /****** ARMIKMCU Swift specific Interrupt Numbers ************************************************/ BOD_IRQn = 0, WDT_IRQn = 1, EINT0_IRQn = 2, EINT1_IRQn = 3, GPAB_IRQn = 4, GPCDE_IRQn = 5, PWM0_IRQn = 6, PWM1_IRQn = 7, TMR0_IRQn = 8, TMR1_IRQn = 9, TMR2_IRQn = 10, TMR3_IRQn = 11, UART0_IRQn = 12, UART1_IRQn = 13, SPI0_IRQn = 14, SPI1_IRQn = 15, SPI2_IRQn = 16, SPI3_IRQn = 17, I2C0_IRQn = 18, I2C1_IRQn = 19, CAN0_IRQn = 20, CAN1_IRQn = 21, SD_IRQn = 22, USBD_IRQn = 23, PS2_IRQn = 24, ACMP_IRQn = 25, PDMA_IRQn = 26, I2S_IRQn = 27, PWRWU_IRQn = 28, ADC_IRQn = 29, DAC_IRQn = 30, RTC_IRQn = 31 } IRQn_Type; The interrupt number is defined in the “NUC1xx.h” file

32 startup_NUC1xx.s (1/2) _Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler DCD HardFault_Handler ; Hard Fault Handler DCD ; Reserved DCD SVC_Handler ; SVCall Handler DCD PendSV_Handler ; PendSV Handler DCD SysTick_Handler ; SysTick Handler These exception names are fixed and define the start of the vector table for a Cortex-M0

33 startup_NUC1xx.s (2/2) ; External Interrupts DCD BOD_IRQHandler DCD WDT_IRQHandler DCD EINT0_IRQHandler DCD EINT1_IRQHandler DCD GPAB_IRQHandler DCD GPCDE_IRQHandler DCD PWMA_IRQHandler DCD PWMB_IRQHandler DCD TMR0_IRQHandler DCD TMR1_IRQHandler DCD TMR2_IRQHandler DCD TMR3_IRQHandler DCD UART02_IRQHandler DCD UART1_IRQHandler DCD SPI0_IRQHandler DCD SPI1_IRQHandler DCD SPI2_IRQHandler DCD SPI3_IRQHandler DCD I2C0_IRQHandler DCD I2C1_IRQHandler DCD CAN0_IRQHandler DCD Default_Handler DCD USBD_IRQHandler DCD PS2_IRQHandler DCD ACMP_IRQHandler DCD PDMA_IRQHandler DCD I2S_IRQHandler DCD PWRWU_IRQHandler DCD ADC_IRQHandler DCD RTC_IRQHandler These interrupt names are fixed and define the start of the vector table for a Cortex-M0

34 PWRCON Register (Structure Bit Field SYSCLK_PWRCON_T Data Type)
31 30 29 28 27 26 25 24 RESERVED 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 PD_WAIT_CPU 7 6 5 4 3 2 1 PWR_DOWN PD_WU_STS WINT_EN WU_DLY OSC10K_EN OSC22M_EN XTL32K_EN XTL12M_EN /* Clock Controller */ typedef struct { __IO uint32_t XTL12M_EN:1; __IO uint32_t XTL32K_EN:1; __IO uint32_t OSC22M_EN:1; __IO uint32_t OSC10K_EN:1; __IO uint32_t WU_DLY:1; __IO uint32_t WINT_EN:1; __IO uint32_t INTSTS:1; __IO uint32_t PWR_DOWN:1; __IO uint32_t PD_WAIT_CPU:1; __I uint32_t RESERVE:23; } SYSCLK_PWRCON_T; LSB New Data Type MSB

35 Group Registers for fixed CLK_BA BaseAddr (SYSCLK_T Data Type)
Offset PWRCON CLK_BA + 00 AHBCLK CLK_BA + 04 APBCLK CLK_BA + 08 CLKSEL0 CLK_BA + 10 CLKSEL1 CLK_BA + 14 CLKSEL2 CLK_BA + 1C CLKDIV CLK_BA_+ 18 PLLCON CLK_BA + 20 FRQDIV GCR_BA + 24 typedef struct { SYSCLK_PWRCON_T PWRCON; SYSCLK_AHBCLK_T AHBCLK; SYSCLK_APBCLK_T APBCLK; uint32_t RESERVED; SYSCLK_CLKSEL0_T CLKSEL0; SYSCLK_CLKSEL1_T CLKSEL1; SYSCLK_CLKDIV_T CLKDIV; uint32_t RESERVED2; SYSCLK_PLLCON_T PLLCON; uint32_t RESERVED3[3]; SYSCLK_TREG_T TREG; } SYSCLK_T;

36 To access register #define AHB_BASE 0x50000000
#define SYSCLK_BASE (AHB_BASE x00200) #define SYSCLK ((SYSCLK_T *) SYSCLK_BASE) AHB Modules Space (0x5000_0000 – 0x501F_FFFF) 0x5000_0000 – 0x5000_01FF GCR_BA System Global Control Registers 0x5000_0200 – 0x5000_02FF CLK_BA Clock Control Registers 0x5000_0300 – 0x5000_03FF INT_BA Interrupt Multiplexer Control Registers 0x5000_4000 – 0x5000_7FFF GPIO_BA GPIO Control Registers 0x5000_8000 – 0x5000_BFFF PDMA_BA SRAM_APB DMA Control Registers 0x5000_C000 – 0x5000_FFFF FMC_BA Flash Memory Control Registers SYSCLK->PWRCON.XTL12M_EN = 1;

37 Cortex-M0 Core Registers Access (core_cm0.h)
Function Definition Core Register Description void __enable_irq (void) PRIMASK = 0 Global Interrupt enable (using the instruction CPSIE i) void __disable_irq (void) PRIMASK = 1 Global Interrupt disable (using the instruction CPSID i) void __set_PRIMASK (uint32_t value) PRIMASK = value Assign value to Priority Mask Register (using the instruction MSR) uint32_t __get_PRIMASK (void) return PRIMASK Return Priority Mask Register (using the instruction MRS) void __set_CONTROL (uint32_t value) CONTROL = value Set CONTROL register value (using the instruction MSR) uint32_t __get_CONTROL (void) return CONTROL Return Control Register Value (using the instruction MRS) void __set_PSP (uint32_t TopOfProcStack) PSP = TopOfProcStack Set Process Stack Pointer value (using the instruction MSR) uint32_t __get_PSP (void) return PSP Return Process Stack Pointer (using the instruction MRS) void __set_MSP (uint32_t TopOfMainStack) MSP = TopOfMainStack Set Main Stack Pointer (using the instruction MSR) uint32_t __get_MSP (void) return MSP Return Main Stack Pointer (using the instruction MRS)

38 Cortex-M0 Instruction Access
Function Name CPU Instruction Description void __WFI (void) WFI Wait for Interrupt void __WFE (void) WFE Wait for Event void __SEV (void) SEV Set Event void __ISB (void) ISB Instruction Synchronization Barrier void __DSB (void) DSB Data Synchronization Barrier void __DMB (void) DMB Data Memory Barrier uint32_t __REV (uint32_t value) REV Reverse byte order in integer value. uint32_t __REV16 (uint16_t value) REV16 Reverse byte order in unsigned short value. sint32_t __REVSH (sint16_t value) REVSH Reverse byte order in signed short value with sign extension to integer.

39 NVIC Setup Function Call
Function Name Parameter Description void NVIC_SetPriorityGrouping (uint32_t PriorityGroup) Priority Grouping Value Set the Priority Grouping (Groups . Subgroups) void NVIC_EnableIRQ (IRQn_Type IRQn) IRQ Number Enable IRQn void NVIC_DisableIRQ (IRQn_Type IRQn) Disable IRQn uint32_t NVIC_GetPendingIRQ (IRQn_Type IRQn) Return 1 if IRQn is pending else 0 void NVIC_SetPendingIRQ (IRQn_Type IRQn) Set IRQn Pending void NVIC_ClearPendingIRQ (IRQn_Type IRQn) Clear IRQn Pending Status void NVIC_SetPriority (IRQn_Type IRQn, uint32_t priority) IRQ Number, Priority Set Priority for IRQn uint32_t NVIC_GetPriority (IRQn_Type IRQn) Get Priority for IRQn uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) IRQ Number, Priority Group, Preemptive Priority, Sub Priority Encode priority for given group, preemptive and sub priority NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority) IRQ Number, Priority, pointer to Priority Group, pointer to Preemptive Priority, pointer to Sub Priority Decode given priority to group, preemptive and sub priority void NVIC_SystemReset (void) (void) Resets the System

40 單晶片實作應用 ARM Cortex-M0 Introduction
樹德科技大學資訊工程系 吳鴻志副教授

41 簡介 主題:讓學生了解單晶片介紹 單元名稱:微處理單片介紹-2 學習時數:3小時 適用對象:資訊工程系大三學生

42 綱要 ARM Processors roadmap ARM Cortex-M0 roadmap Cortex-M0 performance
Cortex-M0 functional blocks Cortex-M0 architecture overview Memory Model Exception Model Cortex-M0 address map System Control Space System Timer NVIC

43 ARM Processors roadmap
Reference from ARM

44 ARM Cortex-M Series roadmap
Reference from ARM

45 Cortex-M0 performance Reference from ARM

46 Cortex-M0 Functional Blocks
Cortex-M0 processor includes Cortex-M0 processor core Nested Vectored Interrupt Controller (NVIC) System Timer (SysTick) Cortex-M0 Processor core Nested Vectored Interrupt Controller (NVIC) System Timer (SysTick) ROM RAM Peripherals Interrupts AHB-Lite interface

47 Cortex-M0 Architecture Overview
ARMv6-M (which is a subset of ARMv7-M, upward compatible) It supports only the Thumb instruction set. No Interworking code is required. Total are 56 instructions. 6 are 32-bit length, the others are 16-bit length 32-bit instructions : BL, DMB, DSB, ISB, MRS, MSR Supports byte (8-bit), halfword (16-bit) and word (32-bit) data types, each must be accessed with natural alignment. Processor modes are Thread and Handler. Always in privilege Supports hardware key context state saving and restoring (Need not Assembly coding for ISR). Built-in timer and interrupt controller NVIC, Systick Memory mapped I/O Use same instructions to access memory and registers Ex : LDR, STR

48 Memory Model 32-bit address space
Virtual memory is not supported in ARMv6-M. Instruction fetches are always halfword-aligned Data accesses are always naturally aligned Ex : word at address A : A, A+1, A+2 and A+3.

49 Exceptional Model An exception may be an interrupt or a hardware error
Each exception has exception number, priority number and vector address Vector address Vector table base address is fixed at 0x 0x Vector address of exception 1 Vector address of exception 2 Initial value of stack Vector address of exception 47 Vector Table Word 0 Word 1 Word 2 Word 47

50 Exception Model – cont. Exceptions defined in Cortex-M0
Exception number Exception Priority level 1 Reset -3 2 NMI -2 3 HardFault -1 11 SVCall configured by register SHPR2 14 PendSV configured by register SHPR3 15 SysTick 16 External Interrupt (0) configured by register NVIC_IPRx 47 External Interrupt (31)

51 Exception Model – cont. Exception priorities and pre-emption
Lower numbers take higher precedence If multiple exceptions have the same priority number, the pending exception with the lowest exception number takes precedence. Only exceptions with a higher priority (lower priority number) can pre-empt an active exception.

52 Context Saving & Restoring
Key context saving and restoring Using full-descending stack format (decremented immediately before storing, incremented after reading) xPSR, ReturnAddress(), LR (R14), R12, R3, R2, R1, and R0 xPSR ReturnAddress LR r12 r3 r2 r1 r0 SP’ SP H Loaded into PC on exception return

53 Cortex-M0 address map Code SRAM Peripheral System
Typically ROM or flash memory, WT 0x – 0x1FFFFFFF SRAM 0x – 0x3FFFFFFF Typically used for on-chip RAM, WBWA Peripheral 0x – 0x5FFFFFFF on-chip peripheral, XN 0x – 0x7FFFFFFF 0x – 0x9FFFFFFF 0xA – 0xBFFFFFFF 0xC – 0xDFFFFFFF System system segment including the PPB, XN 0xE – 0xFFFFFFFF Note 1 : Event entry points (vectors), system control, and configuration are defined at physical addresses Note 2 : A multi-word access which crosses a 0.5GB address boundary is UNPREDICTABLE

54 Setting in Keil Code region SRAM region Program entry point

55 System Control Space (SCS)
Consists of the following groups CPUID space. System control, configuration and status. SysTick system timer Nested Vectored Interrupt Controller (NVIC) 0xE000E xE000E00F Auxiliary Control register 0xE000E xE000E0FF System Timer 0xE000E xE000ECFF NVIC 0xE000ED00 - 0xE000ED8F System control and ID registers 0xE000EDF0 - 0xE000EEFF Debug control and configuration

56 System Control Space – cont.
System control and ID register Address Name Function Type Reset Value 0xE000E008 ACTLR Auxiliary Control Register R/W IMPLEMENTATION DEFINED 0xE000ED00 CPUID CPUID Register RO 0xE000ED04 ICSR Interrupt Control State Register 0x 0xE000ED08 VTOR Vector Table Offset Register 0xE000ED0C AIRCR Application Interrupt/Reset Control Register bits [10:8] = ’000’ 0xE000ED10 SCR System Control Register (optional) bits [4,2,1] = ’000’ 0xE000ED14 CCR Configuration and Control Register bits [9,3] = ’1’ 0xE000ED1C SHPR2 System Handler Priority Register 2 SBZ 0xE000ED20 SHPR3 System Handler Priority Register 3 0xE000ED24 SHCSR System Handler Control and State Register 0xE000ED30 DFSR DebugFault Status Register (Debug Extension only)

57 System Control Space – cont.
Some registers are implementation defined and read-only Ex : CPUID, VTOR Interrupt Control State Register (ICSR) Generate system interrupt request in software manner. NMI, PendSV and SysTick System Handler Priority Registers Set up priority number of system interrupts SHPR2 : SVCall SHPR3 : SysTick and PendSV

58 System Timer - SysTick SysTick provides a simple, 24-bit clear-on-write, decrementing, wrap-on-zero counter. When enabled, the timer will count down. When the counter transitions to zero, the COUNTFLAG status bit is set. The reference clock can be the core clock or an external clock source. 24-bit down count counter Reference clock CPU clock external clock SysTick request when counter reaches 0 Reload counter

59 System Timer – cont. System timer register Address Name Function Type
Reset Value 0xE000E010 SYST_CSR SysTick Control and Status R/W 0x 0xE000E014 SYST_RVR SysTick Reload value UNKNOWN 0xE000E018 SYST_CVR SysTick Current value 0xE000E01C SYST_CALIB SysTick Calibration value RO IMP DEF

60 System Timer – cont. SysTick Control and Status (SYST_CSR)
Enables counting and interrupt Selects reference clock source SysTick Reload value (SYST_RVR) Copied to current value register when counter reaches 0 SysTick Current value (SYST_CVR) Keeps current counter value SysTick Calibration value (SYST_CALIB) Defined by implementation

61 NVIC (Nested Vectored Interrupt Controller)
Upon stack based exception model Restore registers to resume to normal execution automatically Remove redundant PUSH/POP operations needed by traditional C-based ISRs. Benefits over traditional systems Enhancing performance in low MHz systems Provide deterministic response for late arrival and pre-emption Achieve lower latency without state restore and save

62 Tail Chaining Technology
Traditional MCU NuMicro The processor state is automatically saved on interrupt entry, and restored on interrupt exit Fewer cycles than a software implementation, significantly enhancing performance in low MHz systems

63 Late Arrival of Higher Priority Interrupts
Traditional MCU NuMicro NVIC immediately fetches a new vector address to service the pending interrupt Provide deterministic response to these possibilities with support for late arrival and pre-emption

64 Stack Pop Pre-emption Traditional MCU NuMicro Abandon a stack Pop if an exception arrives and service the new interrupt immediately. Achieve lower latency in a deterministic manner by pre-empting and switching to the second interrupt without completing the state restore and save

65 Nested Vectored Interrupt Controller (NVIC)
Supports up to 32 (IRQ[31:0]) discrete interrupts which can be either level-sensitive or pulse-sensitive. NVIC interrupts can be enabled/disabled, pended/un-pended and prioritized by setting NVIC control registers NVIC interrupt 0 : Interrupt 31 Interrupt number Cortex-M0 System interrupts Exception Exception 1 Exception 2 Exception 47 Vector Table

66 NVIC registers Address Name Function Type Reset Value 0xE000E100
NVIC_ISER Irq 0 to 31 Set-Enable Register R/W 0x 0xE000E180 NVIC_ICER Irq 0 to 31 Clear-Enable Register 0xE000E200 NVIC_ISPR Irq 0 to 31 Set-Pending Register 0xE000E280 NVIC_ICPR Irq 0 to 31 Clear-Pending Register 0xE000E400 NVIC_IPR0 Irq 0 to 3 Priority Register 0xE000E404 NVIC_IPR1 Irq 4 to 7 Priority Register 0xE000E408 NVIC_IPR2 Irq 8 to 11 Priority Register 0xE000E40C NVIC_IPR3 Irq 12 to 15 Priority Register 0xE000E410 NVIC_IPR4 Irq 16 to 19 Priority Register 0xE000E414 NVIC_IPR5 Irq 20 to 23 Priority Register 0xE000E418 NVIC_IPR6 Irq 24 to 27 Priority Register 0xE000E41C NVIC_IPR7 Irq 28 to 31 Priority Register

67 NVIC – cont. Interrupt Set-Enable and Clear-Enable Registers
NVIC_ISER : write 1 to enable interrupt NVIC_ICER : write 1 to disable interrupt Interrupt Set-Pending and Clear-Pending Registers NVIC_ISPR : write 1 to generate interrupt request NVIC_ICPR : write 1 to remove interrupt request Interrupt Priority Registers NVIC_IPR0 ~ NVIC_IPR7 Each priority register can set up priority number of four interrupts

68 Cortex-M0 Summary Cortex-M0 is always in privileged mode and supports Thumb instruction only. Supports key context saving and restoring xPSR, return address, r14, r12, r3, r2, r1, r0 System address map is defined in advance. Code, SRAM, Peripheral, System Contains SysTick and NVIC


Download ppt "單晶片實作應用 ARM Cortex-M0 Introduction"

Similar presentations


Ads by Google