0% found this document useful (0 votes)
132 views46 pages

Numicro Mcu Learning Board: Department of Electrical Engineering

Uploaded by

Szilárd Májer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views46 pages

Numicro Mcu Learning Board: Department of Electrical Engineering

Uploaded by

Szilárd Májer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 46

NuMicro MCU Learning Board

Introduction

Department of Electrical Engineering,


www.ee.ntou.edu.tw
National Taiwan Ocean University

3/7/2013

Richard Kuo
Assistant Professor
Outline
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

► NuMicro NUC140 Learning Board


► Nu-LB-NUC140 schematics
► SDK installation
► Learning Board Basic Sample Package
► Keil Development Environment Setup
NuMicro MCU Learning Board (Nu-LB-NUC140)
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
ICE Bridge CAN/LIN
Nu-Link
UART
5V DC
Power

USB
Device
WAU8822
Codec
NUC140VE3AN
Line out EEPROM
SPI Flash
LED
Line in Reset
SW int
3x3 Key Matrix
GPIO
Buzzer
Variable
Resistance
NuMicro MCU Learning Board (bottom view)
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

SD Card
Learning Board Power Supply
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► Basic Supply Voltage is 5V, there are 3 ways to supply power :
– ICE_USB : mini USB connector for on-board NuLink ICE
– CON5: DC supply connector
– POWER1: VCC & GND pins (beside CON5)
– J3: mini USB of NUC140 device

► Learning Board provide +5V, +3.3V power on the lower-right side


3VVC1 = 3.3V, 5VCC1 = 5V, VCC = 5V, GND1 = GND
max. current is depending on the power supply source, if connecting to PC
USB port, its current is about 500mA

Note: During the excerise/experiement, PC may cut off power of USB port if
short circuit happens. Please reset the PC to resume the power supply from
USB port.
Learning Board Connectors
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► VCC5 = +5V, VCC33 = +3V
► ICE_USB: NuLink’s miniUSB port for connecting to PC
► CON2: RS232 port
► CON5 : DC power supply (+5V)
► SW_POW : DC power switch (on/off control of CON5 to board)
► POWER1 : System Power connector pins (for jumping wire to power
the board when use external voltage converter as power supply)
► J3 : NUC140 USB port (when NUC140 serve as USB device)
► J1 : audio output (connect to earphone)
► J2 : audio input (connect to mic)
► RESET : reset button (below on-board LCD)
► SW_INT : soft interrrupt button (below RESET button)
Learning Board function and used pins
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
NU-LB-NUC140 Pin & Function
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

Block Pin Function


ICE Bridge Nu-Link ICE_CLK SWD interface
ICE_DATA
UART GPB0 UART0 Rx
GPB1 UART0 Tx
WAU8822 codec GPC0 I2SLRCLK
GPC1 I2SBCLK
GPC2 I2SDI
GPC3 I2SDO
GPA15 I2SMCLK
GPA8 I2C0 SDA
GPA9 I2C0 SCL
GPE14 Line out Enable/Disable
GPE15 Line in plug in/out detect
Key GPB15 GPB15 INT1
NU-LB-NUC140 Pin & Function
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
Block Pin Function
CAN GPD6 CAN0 Rx
GPD7 CAN0 Tx
GPB12~13 CAN transceiver speed
LIN GPB4 UART1 Rx
GPB5 UART1 Tx
GPB6 LIN transceiver wakeup function
GPB7 LIN transceiver Enable/Disable
7-Seg LED GPE0~7 Row
GPC4~7 Column
Black Dot Matrix LCD GPD8 SPI3 SS30
Panel GPD9 SPI3 SPCLK
GPD10 LCD Reset
GPD11` SPI3 MOSI0

GPD14 Background Enable/Disable


NU-LB-NUC140 Pin & Function
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
Block Pin Function
Variable Resistance GPA7 ADC interface
Buzzer GPB11 PWM4
Key Matrix GPA0~5 GPIO

Reset RESET Reset


EEPROM GPA10 I2C1 SDA
GPA11 I2C1 SCL
FLASH GPD0 SPI2 SS20
GPD1 SPI2 SPCLK
GPD2 SPI2 MISO0
GPD3 SPI2 MOSI0
GPD4 SPI2 MISO1
GPD5 SPI2 MOSI1
NU-LB-NUC140 Pin & Function
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
Block Pin Function
LED GPA12 PWM0
GPA13 PWM1
GPA14 PWM2
GPC12~15 GPIO

SD card GPD12 SD card Power Enable/Disable


GPD13 SD card insert detection
GPC8 SPI1 SS10
GPC9 SPI1 SPCLK
GPC10 SPI1 MOSI0
GPC11 SPI1 MISO0
Learning Board Schematics
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

► 7-segment schematic
► 64x128 LCD schematic
► RGB LED schematic
► Keypad & SW_INT schematic
► UART/RS232 schematic
► I2C & Buzzer schematic
► SPI schematic
► PS2 & ADC schematic
► I2S schematic
► CAN & LIN schematic
► SD card schematic
7 segment schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPE0~7, GPC4~7
64x128 LCD schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPD8~11
RGB LED schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPA14 control Red color


GPA13 control Green color
GPA12 control Red color
Output low to enable R/G/B LEDs
Red LED schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPC12,13,14,15
(output low to enable LED)
Keypad & SW_INT schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPA0~5 GPB15
UART/RS232 schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPB0,1
I2C & Buzzer schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPA10,11 GPB11
SPI schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPD0~5
PS2 & ADC schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPA7
I2S schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPA8,9
GPA15
GPC0~3
CAN & LIN schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

CAN : GPD6,7
LIN : GPB4~7
SD card schematic
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

GPD12,13
GPC8~11
Learning Board GPIO pin assignment
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

► NuMicro MCU Learning Board has 5 group of GPIO


pin : GPIOA, GPIOB, GPIOC, GPIOD, GPIOE

► They are named GPA, GPB, GPC, GPD, GPE


– Sample code use E_GPA, E_GPB, E_GPC, E_GPD, E_GPE as its
defined port name

► GPIO pins are allocated at the pins at the lower part of


the learning board : J4, J5, J6, J7, J8

► You can jump wire to external device with these pins


GPIO group A, B
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

JP4: GPIOA JP5 : GPIOB


GPIO group C, D
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

JP6 : GPIOC JP7 : GPIOD


GPIO group E
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

JP8 : GPIOE
NuLink ICE used with PC
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

NuLink ICE is built-in on board with miniUSB connector


SDK Installation
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► Before connecting NuMicro MCU Learning Board to PC, you will
need install the following :
– Keil/IAR Tools (for program editting, compiling, debugging)
– NuLink device driver (NuLink USB driver for PC)
– Nuvoton BSP (Learning board sample codes from Nuvoton)
► After the above installation, you can connect the miniUSB port of
NuLink (upper side of the NUC140 learning board) , and
– Build (compile) your sample code into binary file, and Download (burn)
thru NuLink to NUC140 on the learning board
– Then press Reset button to execute the new code inside NUC140
– Or you can unplug and reconnect USB cable which is also reset the entire
system to restart with new code

Nuvoton provide NuMicro SDK CDROM with free software tools & sample codes,
you can also download the latest driver and sample code from www.nuvoton.com
Quick New Project Creation (Keil example)
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► Create a new project folder Smpl_newproj
► Copy 3 files from old sample project
– smpl_old.uvproj
– smpl_old.uvopt
– smpl_old.c
► Rename 3 files into new sample name
– smpl_new.uvproj
– smpl_new.uvopt
– smpl_new.c
► Change to new project folder, double click on smpl_new.uvproj
– the error message show up is smpl_old.c is missing (because we rename it to smpl_new.c)
– Move cursor to the left side of the Keil window
– Point to smpl_old.c & right mouse click, a menu will show up, please choose “remove from the
project”
– Point cursor to Source Files, and right mouse click, a file window will show up, then select
smpl_new.c to add into the project Source Files
– Point cursor to window left top corner, and revise the project name from smpl_old to smpl_new
Build and Download Binary Code into MCU
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► At Keil project window, top menu select Flash , select Configure Flash Tools…
– it will show up a configuration window : Options for Target ‘Smpl_new’
– select Output, and rename Smpl_old to Smpl_new
– select Target to confirm the correct Target Device is Nuvoton NUC140VE3AN (learning
board MCU)
– select Debug to use Nu-Link Debugger
– select Utilities to use Target Driver Nu-Link Debugger
– select OK on the bottom of the configuration window

► To build project (compile C code into binary code)


– Keil command menu , press F7 / Build Target , or select Project and select Build Target
– If shown 0 error on the console (the bottom of project window), the binary code will be
generated, Else you need to debug the error
– Click on the error message in the console, it will takes you to the line of error code

► To download binary code into MCU chip


– Press Download, or menu select Flash and select Download
Setup for using printf function
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► NuMicro has a printf function of C for MCU, the following steps will direct printf
output to UART0 :
Step 1. startup_NUC1xx.s line #10 FALSE changed to TRUE
SEMIHOSTED SETL {TRUE}
Step 2. retarget.c around line #20 to add
#define DEBUG_ENABLE_SEMIHOST
(also retarget.c need to be added to Library Files of the current project, retarget.c can be
found in src/NUC1xx-LB_002/ )
Step 3. add printf statement into the C code
printf will print message to UART0, so it will slow down the program due to using UART0
to PC, so we recommend to remove printf statement after debug is done
Step 4. Build project and Download code into MCU
Step 5. Open Debugger Session of Keil, and open UART1 of view window
Step 6. Run (F5)
Basic Sample Package
NUC100SeriesBSP\NuvotonPlatform_Keil\Sample\NUC1xx-LB_002\

Department of Electrical Engineering, www.ee.ntou.edu.tw


National Taiwan Ocean University
► Smpl_ADC_PWM : ADC input to control PWM output
► Smpl_Capture : PMW input (GPA13,14), Catpure Input (GPA12)
► Smpl_FATFS_SDCard : build FAT system and read SDCard
► Smpl_FMC : reset button to boot in AP (ICP mode), soft Interrupt button to boot in LDROM
(ISP mode)
► Smpl_HID_IO : PC run HID application to control LEDs on learning board
► Smpl_I2C_24LC64 : press 3x3 keypad to control read/write 8KB EEPROM (24LC64)
► Smpl_Interrupt : press soft interrupt buttong to control LED flashing
► Smpl_LIN_Master : LIN bus master program code
► Smpl_LIN_Slave : LIN bus slave program code
► Smpl_SPI_Flash_PDMA : SPI read 16MB flash memory (W25Q16)
► Smpl_SPI_Flashx2 : SPI dual-wire mode to read 16MB flash memory (W25Q16)
► Smpl_Start_Kit : starter kit example, it will display message on LCD and 7 segment LEDs
► Smpl_Timer_WDT_RTC : Timer, WatchDog Timer, RTC alarm, and display RTC time
► Smpl_UAC : PC play mp3 file, and USB port to learning board output to earphone jack
► Simpl_UDC : USB to SDCard
► Smpl_VCOM : USB Virtual Com. port
Smpl_ADC_PWM System Diagram
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

VCC

Flash
ADC7 VR1
ADC 20K

G PA 7
Cortex-M0
SPI
ADC Value: 277

LCD Panel
PWM0
NUC140V3AN LED

Function: adjusting VR1 to change PWM frequency and control LED flashing
Smpl_Capture System Diagram
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

LCD Panel
Capture demo
SPI High:683usec
Flash
Low: 683usec

Capture0

Cortex-M0
PWM1

PWM2
NUC140V3AN
Function : PWM pins perform to capture input
Smpl_Capture Pin Usage
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► Capture0
– Input Channel:GPA12
– Counter unit: 1usec (((11+1)*1)/12M)
– Capture capability: 32 bits (hardware 16bits+ firmware 16bits)
► PWM1
– Output Channel:GPA13
– Period: 1.049 sec (((11+1)*16*(65535+1))/12M)
– High level: 262msec, Low level: 786msec
► PWM2
– Output Channel:GPA14
– Period: 1365.3 usec (((1+1)*1*(8191+1))/12M)
– High level: 682usec, Low level: 682usec
► LCD
– Display Capture0 result
Smpl_FMC function description
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

► MCU boot in APROM


► LED rotates left
► Press SW_INT to ISP function and Boot from LD
► MCU boot in LDROM
► MCU reset, after MCU boot in LDROM
► LED rotates right and flash

reset button to boot in AP (ICP mode),


soft Interrupt button to boot in LDROM (ISP mode)
Smpl_I2C_24LC64 System Diagram
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

Flash

I2C0SCL I2C_CLK
Cortex-M0 I2C 24LC64
I2C0SDA I2C_DATA

NUC140V3AN

Function: using I2C to read/write EEPROM (24LC64)


Smpl_SPI_Flash_PDMA System Diagram
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

SPICLK2 CLK
MISO20
SPI2 DO
MOSI20 DI
SPISS20 /CS

NUC140V3AN SPI-Flash
(W25Q16BV)

PDMA

Function : using SPI to read/write 16MB flash memory (W25Q16)


Smpl_SPI_Flash_PDMA SPI setting
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
► Master mode
► One channel data in/out
► SPI clock rate 1MHz
► Transmit data at negative edge
► Receive data at positive edge
► Disable the auto slave select
► Slave select is active low
► SPICLK2(GPD1) <--> SPI-Flash0_CLK (pin 6)
► MISO20(GPD2) <--> SPI-Flash0_DO (pin 2)
► MOSI20(GPD3) <--> SPI-Flash0_DI (pin 5)
► SPISS20(GPD0) <--> SPI-Flash0_/CS (pin 1)
Smpl_SPI_Flashx2 System Diagram
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
SPI-Flash (W25Q16BV)

SPICLK2 CLK
MISO20 DO
MOSI20 DI
SPI2 MISO21 /CS
MOSI21
SPISS20

NUC140V3AN
CLK
DO
DI
/CS

SPI-Flash (W25Q16B)

Function : using SPI dual-wire mode to read/write flash memory (W25Q16)


Smpl_UAC System Diagram
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

PC
USB
Flash

I2C0SCL
Cortex-M0 I2C I2C0SDA
WAU8822

I2SDI
I2S I2SDO

NUC140V3AN
Function : MP3 player , PC play mp3 file and send audio data to USB,
NuMicro learning board receive data from USB and use I2S send to audio codec
(WAU8822), then output to earphone or speaker
Smpl_UDC System Diagram
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University

PC

USB
Flash

Cortex-M0 SPI SD card

NUC140V3AN

Function : USB SDcard reader


General Disclaimer
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
The Lecture is strictly used for educational purpose.

MAKES NO GUARANTEE OF VALIDITY


►The lecture cannot guarantee the validity of the information found here. The lecture may recently have been
changed, vandalized or altered by someone whose opinion does not correspond with the state of knowledge in the relevant
fields. Note that most other encyclopedias and reference works also have similar disclaimers.
No formal peer review
►The lecture is not uniformly peer reviewed; while readers may correct errors or engage in casual peer review, they have
no legal duty to do so and thus all information read here is without any implied warranty of fitness for any purpose or use
whatsoever. Even articles that have been vetted by informal peer review or featured article processes may later have been
edited inappropriately, just before you view them.
No contract; limited license
►Please make sure that you understand that the information provided here is being provided freely, and that no kind of
agreement or contract is created between you and the owners or users of this site, the owners of the servers upon which it is
housed, the individual Wikipedia contributors, any project administrators, sysops or anyone else who is in any way
connected with this project or sister projects subject to your claims against them directly. You are being granted a limited
license to copy anything from this site; it does not create or imply any contractual or extracontractual liability on the part of
Wikipedia or any of its agents, members, organizers or other users.
►There is no agreement or understanding between you and the content provider regarding your use or modification of
this information beyond the Creative Commons Attribution-Sharealike 3.0 Unported License (CC-BY-SA) and the GNU
Free Documentation License (GFDL);
General Disclaimer
Department of Electrical Engineering, www.ee.ntou.edu.tw
National Taiwan Ocean University
Trademarks
►Any of the trademarks, service marks, collective marks, design rights or similar rights that are mentioned, used or cited in
the lectures are the property of their respective owners. Their use here does not imply that you may use them for any
purpose other than for the same or a similar informational use as contemplated by the original authors under the CC-BY-
SA and GFDL licensing schemes. Unless otherwise stated , we are neither endorsed by nor affiliated with any of the
holders of any such rights and as such we cannot grant any rights to use any otherwise protected materials. Your use of any
such or similar incorporeal property is at your own risk.
Personality rights
►The lecture may portray an identifiable person who is alive or deceased recently. The use of images of living or recently
deceased individuals is, in some jurisdictions, restricted by laws pertaining to personality rights, independent from their
copyright status. Before using these types of content, please ensure that you have the right to use it under the laws which
apply in the circumstances of your intended use. You are solely responsible for ensuring that you do not infringe someone
else's personality rights.

You might also like