Nuvoton NuMicro Series User Manual

Nuvoton NuMicro Series User Manual

Arm cortex-m 32-bit microcontroller, numaker numicropy
Hide thumbs Also See for NuMicro Series:

Advertisement

Quick Links

NuMaker
®
®
Arm
Cortex
-M
32-bit Microcontroller
®
NuMicro
Family
NuMicroPy
User Manual
The information described in this document is the exclusive intellectual property of
Nuvoton Technology Corporation and shall not be reproduced without permission from Nuvoton.
Nuvoton is providing this document only for reference purposes of NuMicro microcontroller based system
design. Nuvoton assumes no responsibility for errors or omissions.
All data and specifications are subject to change without notice.
For additional information or questions, please contact: Nuvoton Technology Corporation.
www.nuvoton.com
Mar 29, 2019
Page 1 of 31
Rev 1.00

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the NuMicro Series and is the answer not in the manual?

Questions and answers

Summary of Contents for Nuvoton NuMicro Series

  • Page 1 The information described in this document is the exclusive intellectual property of Nuvoton Technology Corporation and shall not be reproduced without permission from Nuvoton. Nuvoton is providing this document only for reference purposes of NuMicro microcontroller based system design. Nuvoton assumes no responsibility for errors or omissions.
  • Page 2: Table Of Contents

    Embedded Flash Partition ................5 Modules and I/O Classes Support List ............. 6 How to Start NuMicroPy ................9 Nuvoton Nu-Link Driver Download and Install ............ 9 Hardware Setup Steps ................9 Burn Firmware ..................10 Python Code Update Steps ................. 11 How to Customize MicroPython Firmware ...........
  • Page 3: Rev 1.00

    NuMaker Accel Class .................... 28 Gyro Class ..................... 28 Mag Class ....................28 Summary ..................29 Revision History .................. 30 Mar 29, 2019 Page 3 of 31 Rev 1.00...
  • Page 4: Overview

    NuMaker OVERVIEW ® NuMicroPy is the port of MicroPython to Nuvoton NuMicro family microcontrollers (MCUs). The MicroPython project aims to put an implementation of Python 3.x on the microcontrollers and small embedded systems. Refer to Table 1-1 for NuMicroPy support status.
  • Page 5: Numicropy Introduction

    NuMaker NUMICROPY INTRODUCTION The MicroPython divides the code into two parts, python interpreter firmware (firmware.bin) and the user’s python code. The firmware must be burned into the MCU first. After boot, the firmware executes the user’s python code. The execution of the python code supports the REPL mode and/or performs the python code from storage.
  • Page 6: Modules And I/O Classes Support List

    NuMaker force the firmware into USB mass storage mode and then write your python code to these files. Table 2-1 shows the default embedded Flash partition status. Embedded Firmware Firmware Data Data Flash Size Partition Start Partition Size Partition Partition Address Start Size...
  • Page 7: Rev 1.00

    NuMaker  utime Time related functions  uzlib zlib decompression  _thread Multithreading support  network Network configuration  uctypes Access binary data in a structured way  Machine Functions related to the hardware  ucryptolib Cryptographic ciphers Table 2-2 Default Supported Modules I/O Class Description M487...
  • Page 8: Rev 1.00

    NuMaker Gyro Gyroscope control (Bosch BMX055) Only for NuMaker-IOT- M487 Magnetometer control (Bosch BMX055) Only for NuMaker-IOT- M487 Table 2-3 Default Supported I/O Classes Mar 29, 2019 Page 8 of 31 Rev 1.00...
  • Page 9: How To Start Numicropy

    MCU and how to update your python code. Nuvoton Nu-Link Driver Download and Install Please visit the Nuvoton software download website to download “Nu-Link_Command_Tool” file. When the Nu-Link command tool has been downloaded successfully, please unzip the file and execute the “NuMicro NuLink Command Tool.exe” to install the driver.
  • Page 10: Burn Firmware

    NuMaker Figure 3-3 Serial Port Setup Burn Firmware The Nu-Link-Me exports a MBED disk, just Copy and Paste your firmware.bin into MBED disk (Figure 3-4). After firmware burning, you can see MicroPython prompt on your terminal screen as Figure 2-1. You can get prebuilt firmware from NuMicroPy repository Figure 3-4 Copy and Paste Firmware...
  • Page 11: Python Code Update Steps

    NuMaker Python Code Update Steps Connect USB1.1 to PC Press the SW2 and RESET button at the same time. The firmware will export a PYBFLASH disk (Figure 3-5). Update your python code to boot.py or main.py (Figure 3-6). Press the RESET button (Figure 3-7). Figure 3-5 PYBFLASH Disk Figure 3-6 Write Switch Button Example Code Mar 29, 2019...
  • Page 12: Rev 1.00

    NuMaker Figure 3-7 Execute Switch Button Example Code Mar 29, 2019 Page 12 of 31 Rev 1.00...
  • Page 13: How To Customize Micropython Firmware

    NuMaker HOW TO CUSTOMIZE MICROPYTHON FIRMWARE The development of MicroPython firmware is in the Unix-like environment. The description below uses Ubuntu 16.04. Packages Requirement The following packages will need to be installed before you can compile and run MicroPython.  build-essential ...
  • Page 14: Rev 1.00

    NuMaker #define MICROPY_QSTR_BYTES_IN_HASH #define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool #define MICROPY_ALLOC_PATH_MAX (256) #define MICROPY_ALLOC_PARSE_CHUNK_INIT (16) #define MICROPY_EMIT_X64 #define MICROPY_EMIT_THUMB #define MICROPY_EMIT_INLINE_THUMB #define MICROPY_COMP_MODULE_CONST #define MICROPY_COMP_CONST #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0) #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0) #define MICROPY_MEM_STATS #define MICROPY_DEBUG_PRINTERS #define MICROPY_GC_ALLOC_THRESHOLD #define MICROPY_REPL_EVENT_DRIVEN #define MICROPY_HELPER_LEXER_UNIX #define MICROPY_ENABLE_SOURCE_LINE #define MICROPY_ENABLE_DOC_STRING #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
  • Page 15: Enable/Disable I/O Class

    NuMaker // Python internal features #define MICROPY_ENABLE_GC #define MICROPY_READER_VFS #define MICROPY_HELPER_REPL Enable/Disable I/O Class The MicroPython defines I/O classes in pyb and machine modules. User can modify mpconfigboard.h to enable/disable I/O classes or modify the pin definitions for individual I/O class. The I/O class support is disabled if the definition of I/O pin is deleted.
  • Page 16: Rev 1.00

    NuMaker PortA,PA5,MFPL,SPIM0_D2,QSPI0_MISO1,SPI1_I2SMCLK,SD1_CMD,SC2_nCD,UART0_nCTS,UART5_TX D,I2C0_SCL,CAN0_TXD,BPWM0_CH5,EPWM0_CH0,QEI0_INDEX,EVENTOUT, PortB,PB0,MFPL,SPI0_I2SMCLK,SD0_CMD,UART2_RXD,I2C1_SDA,EPWM0_CH5,EPWM1_CH5,EPWM0_BRA KE1,OPA0_P,EBI0_ADR9,EADC0_CH0,EVENTOUT, PortB,PB1,MFPL,EADC0_CH1,OPA0_N,EBI0_ADR8,SD0_CLK,EMAC0_RMII_RXERR,SPI1_I2SMCLK,SPI3 _I2SMCLK,UART2_TXD,USCI1_CLK,I2C1_SCL,I2S0_LRCK,EPWM0_CH4,EPWM1_CH4,EPWM0_BRAKE0,EVE NTOUT, Mar 29, 2019 Page 16 of 31 Rev 1.00...
  • Page 17: O Class Quick Reference

    NuMaker I/O CLASS QUICK REFERENCE The MicroPython provides the document to describe how to access MCU’s I/O by python language, and, has description to introduce how to add a module written in C. This document ® only provides the NuMicro MCU’s I/O quick reference for you reference.
  • Page 18: Rev 1.00

    NuMaker LEDR LEDY LEDG Table 5-1 Board Pin Name and CPU Pin Name Mapping from import p_d0 = Pin(Pin.board.D0, Pin.OUT) # create output pin on GPIO B2 p_d0.value(1) # set pin to on/high p_d1 = Pin(Pin.board.D1, Pin.IN) # create input pin on GPIO B3 print(p_d1.value()) # get value, 0 or 1 Pin.board.D2.af_list()
  • Page 19: Adc Class

    NuMaker  Pin.ALT_OPEN_DRAIN – configure the pin for alternate function, open-drain  pull can be one of: Pin.PULL_NONE – no pull up or down resistors   Pin.PULL_UP – enable the pull-up resistor  Pin.PULL – enable the pull-down resister ...
  • Page 20: I 2 C Class

    NuMaker SPI0_MISO SPI0_MOSI SPI3_NSS SPI3_SCK SPI3_MISO SPI3_MOSI Table 5-3 SPI Support List from import # construct an SPI bus on the SPI0 # mode is Master # polarity is the idle state of SCK # phase=0 means sample on the first edge of SCK, phase=1 means the second spi = SPI(0, SPI.MASTER, baudrate=100000, polarity=1, phase=0) spi.read(10) # read 10 bytes on MISO...
  • Page 21: Rtc Class

    NuMaker from import i2c = I2C(1, I2C.MASTER) # create and initiate I2C1 as a master i2c.scan() # scan for slaves on the bus, returning a list of valid addresses. Only valid when in master mode. i2c.is_ready(0x42) # check if slave 0x42 is ready i2c.send('123', 0x42) # send 3 bytes to slave with address 0x42 data = bytearray(3)
  • Page 22: Can Class

    NuMaker uart.deinit() # turn off the UART bus UART(bus, buadrate, [bits=8, parity=None, stop=1, timeout=2000, flow=0, timeout_char=0, read_buf_len=64])  baudrate is the clock rate.  bits is the number of bits per character, 5, 6, 7 or 8.  parity is the parity, None, 0(even) or 1(odd). ...
  • Page 23: Usb Hid Class

    NuMaker  baudrate is the clock rate can.setfilter(id=0, fifo=0, mask=0)  id is the identifier of the frame that will be received.  fifo is the FIFO number, from 0 to 31.  mask is the identifier mask used for a acceptance filtering. can.recv(fifo=0, list=None, timeout=5000) ...
  • Page 24: Led Class

    NuMaker LED Class The LED object controls an individual LED. Table 5-7 is LED support list by the board. Board LED Name Board Pin Name CPU Pin Name NuMaker_PFM_M487 led0 LEDR led1 LEDY led2 LEDG Table 5-7 LED Support List from import led = LED('led0')
  • Page 25: Pwm Class

    NuMaker tim.callback(tick) # set the function to be called when the timer triggers # configure timer to be a PWM, output compare, or input capture channel chan = tim.channel(Timer.PWM, pin = Pin.board.D0, pulse_width_percent = 20) chan.callback(tick) # set the function to be called when the timer channel triggers chan.capture() # get the capture associated with a input capture channel chan.compare(100)
  • Page 26: Rev 1.00

    NuMaker BPWM0_CH4 BPWM0_CH5 BPWM1_CH2 BPWM1_CH3 BPWM1_CH4 BPWM1_CH5 EPWM0_CH0 EPWM0_CH1 EPWM0_CH2 EPWM0_CH3 EPWM0_CH4 EPWM0_CH5 EPWM1_CH0 EPWM1_CH1 EPWM1_CH2 EPWM1_CH3 EPWM1_CH4 EPWM1_CH5 Table 5-9 PWM Pin Support List from import from import capture_cb(chan, reason): reason == PWM.RISING: Mar 29, 2019 Page 26 of 31 Rev 1.00...
  • Page 27: Rev 1.00

    NuMaker print('rising edge') elif reason == PWM.FALLING: print('falling edge') else: print('both edge') bpwm1 = PWM(1, freq = 2) # create BPWM1 object epwm0 = PWM(0, PWM.EPWM, freq = 8) #create EPWM0 object # configure bpwm 1 channel 4 to be a output channel. Board pin A1, CPU pin B7 bpwm1ch4 = bpwm1.channel(mode = PWM.OUTPUT, pulse_width_percent = 50, pin = Pin.boar d.A1) # configure epwm 0 channel 1 to be a capture channel.
  • Page 28: Wdt Class

    NuMaker WDT Class from import wdt = WDT(timeout = 1000) # start watchdog timer wdt.feed() # reset watchdog timer counter WDT(timeout=5000)  timeout specifies the time-out interval and the interval is 2~ 26000ms Accel Class from import Accel a = Accel(range = Accel.RANGE_4G) # create and return an accelerometer object ax = a.x() # get x axis value...
  • Page 29: Summary

    NuMaker SUMMARY The MicroPython is a Python programming language interpreter that runs on the small embedded system. With MicroPython you can write clean and simple Python code to control hardware instead of having to use complex low-level languages like C or C++. The MicroPython is only a programming language interpreter and does not include an IDE, but you can write code in your desired text editor and then use Copy and Paste (file access) to upload and run the code on a board.
  • Page 30: Revision History

    NuMaker REVISION HISTORY Date Revision Description 2019.03.29 1.00 Initially issued. Mar 29, 2019 Page 30 of 31 Rev 1.00...
  • Page 31 NuMaker Important Notice Nuvoton Products are neither intended nor warranted for usage in systems or equipment, any malfunction or failure of which may cause loss of human life, bodily injury or severe property damage. Such applications are deemed, “Insecure Usage”.

Table of Contents