3/6/2017 Richard Kuo Assistant Professor NuMicro SDK & Keil MDK 3/6/2017 Richard Kuo Assistant Professor
Outline SDK Installation Open Keil Project Keil MDK Configuration SWD Interface Keil Debug Session ICP & ISP mode Programming
3rd Party Development Tools
SDK Installation Tools (Keil MDK, Nu-Link USB Driver, NuMicro BSP) IDE : ARM Keil MDK https://www.keil.com/demo/eval/arm.htm MDK522.exe (run to install) ICE : NuLink Driver Nu-Link_Keil_Driver_V1.30.6535.zip (unzip & run to install) BSP : MCU device driver & sample code NUC100_120_Series_BSP_CMSIS_Rev3.00.002 (original BSP) https://sourceforge.net/projects/numicroedu/files/Academic/Nu-LB-NUC140/SampleCode/ 2017/11/20
BSP – Basic Software Package libraries used by sample code sample code for reference 2017/11/20
SampleCode folder For NUC140 Learning Board NUC100_120_Series_BSP_CMSIS_Rev3.00.002 is the original basic software package 2017/11/20
Library folder For ARM CPU (Cortex-M0, M4, …) For MCU series (NCU100series.h) For NUC140 onboard device (7-seg, 3x3 keypad, …) For sensors (MPU6050, …) & peripherals (LCD) For MCU standard interface (I2C, SPI, UART, ADC, PWM, GPIO, …) 2017/11/20
sample code directory C:\Nuvoton\SW_Nu_LB_NUC140_v1.1\SampleCode\Nu-LB-NUC140 2017/11/20
Pick one sample code double click to enter the directory 2017/11/20
Sample Code Folder Double click to enter Keil directory 2017/11/20
Sample Code Folder Double click to start Keil project 2017/11/20
Keil IDE (Integrated Development Environment) Save File Debug Session Window View setting Build Download Tool Configuration Source Code View Rebuild File Hierarchy View 2017/11/20
Code Size Assuming Keil MDK compilation result is Program Size: Code=3696 RO-data=2256 RW-data=60 ZI-data=1348 Code : program code (程式碼) RO-data : Read-Only Data (唯讀資料) RW-data : Read/Write Data (讀寫資料) ZI-data : Zero Initialized Data (初始為0的資料) Then Total ROM size = Code + RO-data + RW-data = 3696 + 2256 + 60 = 6012 Bytes Total RAM size = RW-data + ZI-data = 60 + 1348 = 1408 Bytes * Nano102的 ROM size = 32K Bytes, RAM size = 16K Bytes * Evaluation License limit code size at 32KB
Keil Configuration Select Configure Flash Tools…
Click to add extra library path Keil Configuration Click to add extra library path Library path setting 2017/11/20
Debug Session main.c printf display message Select UART#1 to open message view main.c printf display message 2017/11/20
Flash > Configure Flash Tools
Flash > Configure Flash Tools>Device
Flash > Configure Flash Tools>Device Just to confirm device is correct Don’t change anything here ! ROM=128KB SRAM=16KB ROM base address SRAM base address
Flash > Configure Flash Tools>Device Just to confirm device is correct ROM=128KB SRAM=16KB ROM base address SRAM base address No change needed here !
Flash > Configure Flash Tools>Output No change needed here !
Flash > Configure Flash Tools>Listing No change needed here !
Flash > Configure Flash Tools>User No change needed here !
Flash > Configure Flash Tools>C/C++ SEMIHOST debug mode for using printf No change needed here !
Flash > Configure Flash Tools>Asm SEMIHOST debug mode for using printf No change needed here !
Flash > Configure Flash Tools>Linker No change needed here !
Flash > Configure Flash Tools>Debug must use Nu-Link Debugger If you see no Nu-Link Debugger here, then you need to reinstall Nu-Link ICE driver
Flash > Configure Flash Tools>Debug must select correct device series NUC100 is for NUC140, … Nano100 is for Nano102, 112
Flash > Configure Flash Tools>Utilities
Flash > Configure Flash Tools>Utilities
Flash > Configure Flash Tools>Utilities
ARM CoreSight Technology ARM Cortex-M processor-based devices use the ARM CoreSight technology which introduces powerful new debug and trace capabilities Debug Features: Run Control of the processor allowing you to start and stop programs Single Step one source or assembler line Set breakpoints while the processor is running Read/write memory contents and peripheral registers on-the-fly Program internal and external FLASH memory Trace Features: Serial Wire Viewer (SWV) provides program counter (PC) sampling, data trace, event trace, and instrumentation trace information Instruction (ETM) Trace streamed directly to your PC enabling debugging of historical sequences, software profiling, and code coverage analysis
CoreSight Block Diagram
SWD (Serial Wire Debug) The SWD interface pins can be overlaid with JTAG signals, allowing the standard target connectors to be used: TCLK - SWCLK (Serial Wire Clock) TMS - SWDIO (Serial Wire Data Input/Output) TDO - SWO (Serial Wire Output - required for SWV) JTAG and SWD modes are fully supported by ULINK2, ULINK-ME, and ULINKpro. Nu-Link ICE signals : VCC ICE_DAT ICE_CLK RST GND
Programming Mode : ISP vs ICP 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
System Memory Map System Peripheral SRAM 16KB 4KB Code 32KB Application Program Memory (APROM) 0x0000_0000 0x0000_7FFF 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 16KB 4KB 32KB
ICP (In Circuit Programming) NuMicro ICP AP USB SWD NuMicro MCU Vcc, Data, Clk, Rst, Gnd
ISP (In System Programming) NuMicro ISPAP USB-to-UART 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
Setup ISP mode Step 1. use ICP tool to upload MCU’s LDROM code for ISP mode (ICP tool use Nu-Link to upload LDROM) Step 2. run Keil MDK to build a project for MCU binary file Step 3. connect USB-to-UART comm port to Nu-LB-NUC140 UART TX/RX pins (used by LDROM code) Step 4. run ISP tool to download binary into MCU 2017/11/20
1. use ICP tool to upload LDROM code for ISP mode Connect / Disconnect load code 2017/11/20
NuMicro ISP (In System Programming)