1.NuMicro_MCU_Learning_Board_Introduction.ppt

Download Report

Transcript 1.NuMicro_MCU_Learning_Board_Introduction.ppt

NuMicro MCU Learning Board
Introduction
Department of Electrical Engineering,
National Taiwan Ocean University
3/7/2013
Richard Kuo
Assistant Professor
www.ee.ntou.edu.tw
Outline
Department of Electrical Engineering,
National Taiwan Ocean University
► NuMicro
NUC140 Learning Board
► Nu-LB-NUC140 schematics
► SDK installation
► Learning Board Basic Sample Package
► Keil Development Environment Setup
www.ee.ntou.edu.tw
NuMicro MCU Learning Board (Nu-LB-NUC140)
Department of Electrical Engineering,
National Taiwan Ocean University
ICE Bridge
Nu-Link
www.ee.ntou.edu.tw
CAN/LIN
UART
5V DC
Power
USB
Device
WAU8822
Codec
Line out
Line in
SW int
GPIO
Buzzer
Variable
Resistance
NUC140VE3AN
EEPROM
SPI Flash
LED
Reset
3x3 Key Matrix
NuMicro MCU Learning Board (bottom view)
Department of Electrical Engineering,
National Taiwan Ocean University
SD Card
www.ee.ntou.edu.tw
Learning Board Power Supply
Department of Electrical Engineering,
National Taiwan Ocean University
►
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
►
►
►
►
►
►
►
►
►
►
►
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
www.ee.ntou.edu.tw
NU-LB-NUC140 Pin & Function
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
Block
Pin
Function
ICE Bridge Nu-Link
ICE_CLK
ICE_DATA
SWD interface
UART
GPB0
GPB1
UART0 Rx
UART0 Tx
WAU8822 codec
GPC0
GPC1
GPC2
GPC3
GPA15
I2SLRCLK
I2SBCLK
I2SDI
I2SDO
I2SMCLK
GPA8
GPA9
I2C0 SDA
I2C0 SCL
GPE14
Line out Enable/Disable
GPE15
Line in plug in/out detect
GPB15
INT1
Key GPB15
NU-LB-NUC140 Pin & Function
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
Block
Pin
Function
CAN
GPD6
GPD7
CAN0 Rx
CAN0 Tx
GPB12~13
CAN transceiver speed
GPB4
GPB5
UART1 Rx
UART1 Tx
GPB6
LIN transceiver wakeup function
GPB7
LIN transceiver Enable/Disable
GPE0~7
Row
GPC4~7
Column
GPD8
GPD9
GPD10
GPD11`
SPI3 SS30
SPI3 SPCLK
LCD Reset
SPI3 MOSI0
GPD14
Background Enable/Disable
LIN
7-Seg LED
Black Dot Matrix LCD
Panel
NU-LB-NUC140 Pin & Function
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
Block
Pin
Function
Variable Resistance
GPA7
ADC interface
Buzzer
GPB11
PWM4
Key Matrix
GPA0~5
GPIO
Reset
RESET
Reset
EEPROM
GPA10
GPA11
I2C1 SDA
I2C1 SCL
FLASH
GPD0
GPD1
GPD2
GPD3
GPD4
GPD5
SPI2 SS20
SPI2 SPCLK
SPI2 MISO0
SPI2 MOSI0
SPI2 MISO1
SPI2 MOSI1
NU-LB-NUC140 Pin & Function
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
Block
Pin
Function
LED
GPA12
GPA13
GPA14
PWM0
PWM1
PWM2
GPC12~15
GPIO
GPD12
GPD13
SD card Power Enable/Disable
SD card insert detection
GPC8
GPC9
GPC10
GPC11
SPI1 SS10
SPI1 SPCLK
SPI1 MOSI0
SPI1 MISO0
SD card
Learning Board Schematics
Department of Electrical Engineering,
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
www.ee.ntou.edu.tw
7 segment schematic
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
GPE0~7, GPC4~7
64x128 LCD schematic
Department of Electrical Engineering,
National Taiwan Ocean University
GPD8~11
www.ee.ntou.edu.tw
RGB LED schematic
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
GPC12,13,14,15
(output low to enable LED)
www.ee.ntou.edu.tw
Keypad & SW_INT schematic
Department of Electrical Engineering,
National Taiwan Ocean University
GPA0~5
www.ee.ntou.edu.tw
GPB15
UART/RS232 schematic
Department of Electrical Engineering,
National Taiwan Ocean University
GPB0,1
www.ee.ntou.edu.tw
I2C & Buzzer schematic
Department of Electrical Engineering,
National Taiwan Ocean University
GPA10,11
www.ee.ntou.edu.tw
GPB11
SPI schematic
Department of Electrical Engineering,
National Taiwan Ocean University
GPD0~5
www.ee.ntou.edu.tw
PS2 & ADC schematic
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
GPA7
I2S schematic
Department of Electrical Engineering,
National Taiwan Ocean University
GPA8,9
GPA15
GPC0~3
www.ee.ntou.edu.tw
CAN&LIN schematic
Department of Electrical Engineering,
National Taiwan Ocean University
CAN : GPD6,7
LIN : GPB4~7
www.ee.ntou.edu.tw
SD card schematic
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
GPD12,13
GPC8~11
Learning Board GPIO pin assignment
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
►
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,
National Taiwan Ocean University
JP4: GPIOA
www.ee.ntou.edu.tw
JP5 : GPIOB
GPIO group C, D
Department of Electrical Engineering,
National Taiwan Ocean University
JP6 : GPIOC
www.ee.ntou.edu.tw
JP7 : GPIOD
GPIO group E
Department of Electrical Engineering,
National Taiwan Ocean University
JP8 : GPIOE
www.ee.ntou.edu.tw
NuLink ICE used with PC
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
NuLink ICE is built-in on board with miniUSB connector
SDK Installation
Department of Electrical Engineering,
National Taiwan Ocean University
►
►
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
www.ee.ntou.edu.tw
►
Create a new project folder Smpl_newproj
► Copy 3 files from old sample project
–
–
–
►
Rename 3 files into new sample name
–
–
–
►
smpl_old.uvproj
smpl_old.uvopt
smpl_old.c
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,
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)
–
–
–
►
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
►
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
►
►
►
►
►
►
►
►
►
►
►
►
►
►
►
►
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
www.ee.ntou.edu.tw
VCC
ADC7
VR1
ADC
Cortex-M0
GPA7
Flash
20K
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,
National Taiwan Ocean University
www.ee.ntou.edu.tw
LCD Panel
Flash
SPI
Capture0
Cortex-M0
PWM1
NUC140V3AN
PWM2
Function : PWM pins perform to capture input
Capture demo
High:683usec
Low: 683usec
Smpl_Capture Pin Usage
Department of Electrical Engineering,
National Taiwan Ocean University
►
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
► MCU
www.ee.ntou.edu.tw
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,
National Taiwan Ocean University
www.ee.ntou.edu.tw
Flash
Cortex-M0
I2C
I2C0SCL
I2C0SDA
I2C_CLK
I2C_DATA
NUC140V3AN
Function: using I2C to read/write EEPROM (24LC64)
24LC64
Smpl_SPI_Flash_PDMA System Diagram
Department of Electrical Engineering,
National Taiwan Ocean University
SPI2
SPICLK2
MISO20
MOSI20
SPISS20
NUC140V3AN
www.ee.ntou.edu.tw
CLK
DO
DI
/CS
SPI-Flash
(W25Q16BV)
PDMA
Function : using SPI to read/write 16MB flash memory (W25Q16)
Smpl_SPI_Flash_PDMA SPI setting
Department of Electrical Engineering,
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)
www.ee.ntou.edu.tw
Smpl_SPI_Flashx2 System Diagram
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
SPI-Flash (W25Q16BV)
SPI2
SPICLK2
MISO20
MOSI20
MISO21
MOSI21
SPISS20
CLK
DO
DI
/CS
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,
National Taiwan Ocean University
www.ee.ntou.edu.tw
PC
USB
Flash
Cortex-M0
I2C
I2S
I2C0SCL
I2C0SDA
WAU8822
I2SDI
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,
National Taiwan Ocean University
www.ee.ntou.edu.tw
PC
USB
Flash
Cortex-M0
NUC140V3AN
Function : USB SDcard reader
SPI
SD card
General Disclaimer
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
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 (CCBY-SA) and the GNU Free Documentation License (GFDL);
General Disclaimer
Department of Electrical Engineering,
National Taiwan Ocean University
www.ee.ntou.edu.tw
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.