Download Arduino User Manual
Transcript
Arduino ARM® Cortex® -M 32-bit Microcontroller Arduino User Manual for NuMicro™ MCU Series 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 20, 2015 Page 1 of 17 Rev 1.01 ARDUINO 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. Arduino Table of Contents 1 Overview ............................................................................................. 3 2 Arduino IDE Installation ........................................................................... 4 3 Hardware Setup .................................................................................... 6 4 NuEdu Evaluation Board Pin Out ................................................................ 8 4.1 NuEdu-M451 Board ................................................................................... 8 4.2 NuEdu-NUC240 Board................................................................................ 9 4.3 NuEdu-NANO130 Board.............................................................................10 4.4 NuEdu-UNO Board ...................................................................................11 Sample Code ..................................................................................... 12 5 6 5.1 NuEdu-M451 Board ..................................................................................12 5.2 NuEdu-NUC240 Board...............................................................................13 5.3 NuEdu-NANO130 Board.............................................................................14 5.4 NuEdu-UNO Board ...................................................................................15 Revision History .................................................................................. 16 ARDUINO USER MANUAL Mar 20, 2015 Page 2 of 17 Rev 1.01 Arduino 1 OVERVIEW Arduino is an open-source electronics platform based on easy-to-use hardware and software. TM The NuMicro NuEdu Evaluation Board is an Arduino compatible hardware using NuMicro MCU as the microcontroller. Its function can be extended with Arduino add-ons. Users can use Arduino IDE to develop their applications and leverage large number of open source samples. The next chapter introduces the steps to install Arduino IDE and apply patch to support NuMicro NuEdu Evaluation Board. Mar 20, 2015 Page 3 of 17 Rev 1.01 ARDUINO USER MANUAL Figure 1-1 NuMicro NuEdu Board with Different Add-ons Arduino 2 ARDUINO IDE INSTALLATION Please follow the steps below to install Arduino 1.5.8 IDE and apply patch to support NuMicro MCU. Refer to Arduino official website for the usage of Arduino IDE. 1. Download Arduino 1.5.8 IDE from http://arduino.cc/en/Main/OldSoftwareReleases Figure 2-1 Download Arduino 1.5.8 2. Extract arduino-1.5.8-windows.zip to the installation path. ARDUINO USER MANUAL Figure 2-2 Extract Arduino 1.5.8 Mar 20, 2015 Page 4 of 17 Rev 1.01 Arduino 3. Double-click NuMicro Arduino patch (NuMicro_Patch_For_Arduino1.5.8.exe), and input the Arduino 1.5.8 installation path. Figure 2-3 Install NuMicro Arduino Patch 4. After successfully applying the patch, five board names NuEdu-M451, NuEdu-NUC240, NuEdu-NANO130, NuEdu-NUC131, and NuMaker-TRIO can be found in Arduino IDE as shown in the figure below. ARDUINO USER MANUAL Figure 2-4 Installation Complete Mar 20, 2015 Page 5 of 17 Rev 1.01 Arduino 3 HARDWARE SETUP The Arduino IDE consists of source code editor, project build tool and also supports firmware download and UART debug function. To download firmware to NuEdu evaluation board, PC must be connected with the on-board Nu-Link Me using USB cable. The NuEdu Evaluation Board can print out debug message through the USB virtual COM (VCOM) interface. Figure 3-1 NuEdu-UNO Hardware Setup ARDUINO USER MANUAL Figure 3-2 USB Connection on NuEdu-UNO Mar 20, 2015 Page 6 of 17 Rev 1.01 Arduino The VCOM function can be used in Arduino IDE, Keil and IAR. To enable VCOM function on NuLink Me, all SW2 pins need to turn to ON position. Otherwise, turn pin2~4 to OFF position. For the usage of different NuEdu Evaluation Boards, please refer to the user manual respectively. Figure 3-3 Switch Default as UART Mode Pin Number Pin Name Disable VCOM Mode Enable VCOM Mode 1 ICE_VCC On On 2 VCOM_Open Off On 3 VCOM_TX Off On 4 VCOM_RX Off On ARDUINO USER MANUAL Mar 20, 2015 Page 7 of 17 Rev 1.01 Arduino 4 NUEDU EVALUATION BOARD PIN OUT This chapter shows the pin out of different NuEdu Evaluation Boards. 31 30 29 28 27 26 25 24 GPIO 80 79 INT1 78 77 INT0 76 75 74 73 72 71 70 69 68 67 66 65 NC VDD 3VCC RESET VSS POWER 5VCC ADC (0~7) VIN ADC (8~10) VSS GPIO CAN0 DAC0 NuEdu-M451 Board NC 4.1 23 22 21 20 19 18 17 16 NU3 NU2 NU1 SMBus SPI0 ACMP 64 63 NC 62 61 TM1_OUT 60 59 SMART CARD UART1 GPIO 44 VSS SPI2 SPI2 RESET 41 42 VCC 40 SPI2 NU7 TIMER TM0_CAP 43 58 56 NuEdu-EVB-M451 54 I2S 52 NC 50 48 NU8* 32 33 34 35 36 37 38 39 I2C0 UART (1~3) NU5 0 1 UART0 2 3 4 5 6 7 PWM (0~5) NU6 8 9 PWM (6~7) 10 11 12 13 GPIO 14 15 VREF NU4 46 VSS ARDUINO USER MANUAL CLKO I2C1 POWER Figure 4-1 NuEdu-M451 Pin Out Mar 20, 2015 Page 8 of 17 Rev 1.01 Arduino 31 30 29 28 27 26 25 24 GPIO 79 INT1 78 77 INT0 76 75 74 73 72 71 70 69 68 67 GPIO 66 65 VSS 64 63 SPI2 62 61 VCC 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 NC VDD 3VCC VSS 23 22 21 20 19 18 17 16 NU3 80 POWER 5VCC ADC (0~7) GPIO VIN CAN RESET NuEdu-NUC240 Board VSS 4.2 NU2 NU1 SMBus TM1_OUT 44 43 42 41 RESET 40 I2S CLKO NU8* SPI2 NU7 TIMER TM0_CAP SPI2 GPIO NuEdu-EVB-NUC240 NU4 32 33 34 35 36 37 38 39 I2C0 UART (1~2) GPIO NU5 0 1 UART0 2 3 4 5 PWM (0~5) 6 7 NU6 8 9 PWM (6~7) 10 11 12 13 GPIO 14 15 VSS ACMP UART1 VREF SPI1 I2C1 POWER ARDUINO USER MANUAL Figure 4-2 NuEdu-NUC240 Pin Out Mar 20, 2015 Page 9 of 17 Rev 1.01 Arduino 31 30 29 28 27 26 25 24 TM1_OUT GPIO 77 INT0 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 I2S 54 53 52 51 50 49 CLKO 48 47 46 45 NU1 GPIO UART1 GPIO 44 43 42 41 VSS SPI0 NU8* SPI0 RESET VCC 40 SPI0 NU7 TIMER TM0_CAP NU2 NuEdu-EVB-Nano130 GPIO NU4 NU5 32 33 34 35 36 37 38 39 0 I2C0 UART0 UART1 GPIO 1 2 3 4 5 PWM (0~5) 6 7 NU6 8 9 PWM (6~7) 10 11 12 13 GPIO 14 15 VSS GPIO 79 78 VREF SPI1 80 23 22 21 20 19 18 17 16 NU3 SMART CARD GPIO POWER NC ADC (0~7) (8~9) VDD ADC 3VCC GPIO VSS (0~1) 5VCC DAC VIN GPIO RESET NuEdu-NANO130 Board VSS 4.3 I2C1 POWER ARDUINO USER MANUAL Figure 4-3 NuEdu-NANO130 Pin Out Mar 20, 2015 Page 10 of 17 Rev 1.01 Arduino NuEdu-UNO Board 4.4 64 Reserved A0 PB.8 44 CLKO PA.0 A1 STADC ADC_CH0 45 TM0 PWM0 CH4 PA.1 A2 BPWM1 CH2 VDD 3VCC RESET VSS 5VCC I2C1_SCL ADC_CH1 46 VDD VSS UART5 TXD I2C1_SDA PWM0 CH5 PA.2 VSS VIN UART5 RXD ADC_CH2 SCK PWM1 CH0 MISO 27 UART3 TXD 26 PC.1 A3 PC.2 SPI0_CLK 47 SPI0_MISO0 BPWM0 CH1 PA.3 Clock Output Pin BPWM Pin External Interrupt Input Pin USB JACK NuEdu-UNO 8~ 9~ 10~ 11~ 12 13 Reserved Reserved 29 30 38 39 40 28 1 9 8 PA.11 PA.15 PE.5 PB.11 PA.14 PA.13 PA.12 PC.0 PB.14 PA.8 PA.9 PWM0 CH3 PWM0 CH5 PWM0 CH4 PWM0 CH2 PWM0 CH1 PWM0 CH0 SPI0_SS0 INT1 I2C0_SDA I2C0_SCL TM1_EXT TM3 UART5 RXD BPWM0 CH0 UART1 nRTS UART1 nCTS PF.4 PF.5 PA.10 UART1 RXD UART1 TXD PWM1 CH4 PWM1 CH5 PWM1 CH2 I2C0_SCL I2C1_SDA I2C1_SCL VSS 4 PB.5 TM1 ARDUINO USER MANUAL 7~ 6 37 VREF 6~ 5 PB.4 UART5 TXD 5~ PWM1 CH3 3~ 11 7 2~ 10 4~ TX 1 I2C0_SDA RX 0 Rev 1.01 Page 11 of 17 Mar 20, 2015 BPWM0 CH2 ADC_CH3 PWM Pin NUC131 SD2AE MOSI 25 PC.3 PWM1 CH1 Serial Pin A4 Timer Pin A5 ADC Pin 48 Analog-related Pin 49 SPI Pin PA.4 Port Pin PA.5 Power-related Pin ADC_CH4 I2C Pin ADC_CH5 Physical Pin Note: ʺ~ʺ means it has PWM function pin. UART Pin Reserved UART3 RXD UNO Defined Digital Pin* SPI0_MOSI0 BPWM0 CH3 1st Pin UART3 RXD Legend 7~12V Power JACK RESET NuLink-Me Figure 4-4 NuEdu-UNO Pin Out Arduino 5 5.1 SAMPLE CODE NuEdu-M451 Board The following table lists the Arduino samples which have been tested on M451 NuEdu board. 01.Basics AnalogReadSerial BareMinimum Blink DigitalReadSerial Fade Knock 07.Display WiFiWebServerr EEPROM s02_Shock s03_Analog_Hall barGraph RowColumnScanning 08.Strings eeprom_clear eeprom_read s04_Button s05_Remote_emission eeprom_write SPI s06_Passive_Buzzer s07_Laser_transmit LoopBack SPIFlashID Wire s08_full_color_LED s09_Light_break CharacterAnalysis ReadAnalogVoltage 02.Digital StringAdditionOperator StringAppendOperator BlinkWithoutDelay Button StringCaseChanges StringCharacters Debounce DigitalInputPullup StringComparisonOperators StringConstructors master_writer programming_EEPROM StateChangeDetection toneKeyboard 03.Analog StringIndexOf StringLength slave_receiver slave_sender CAN_BUS AnalogInOutSerial StringLengthTrim StringReplace AnalogInput AnalogWriteMega Calibration Fading master_reader s10_two_color_LED s11_Buzzer s12_Analog_temperature s13_Digital_Temperature_Humi dity s14_full_color_LED s15_mercury_tilt_switch receive_check s16_Photoresistor s17_Relay StringStartsWithEndsWith StringSubstring receive_interrupt send s18_tilt_switch s19_mini_reed StringToInt StringToIntRGB 10.StarterKit set_mask_filter_recv OneWire s20_Remote_Receive s21_Joystick_PS2 p02_SpaceshipInterface DS18x20_Temperature NuEdu_Basic s22_Linear_Hall s23_reed ASCIITable Dimmer p03_LoveOMeter p04_ColorMixingLamp ADCtoPWM Button s24_Flame s25_Magic_light_cup Graph Midi p06_LightTheremin p07_Keyboard Buzzer EEPROM s26_Digital_Temperature s27_two_color_LED MultiSerialMega PhysicalPixel p08_DigitalHourglass p09_MotorizedPinwheel IRremote LED s28_Knock s29_Avoid ReadASCIIString SerialCallResponse p10_Zoetrope p14_TweakTheArduinoLogo RGBLED SevenSegmentDisplay s30_7_color_LED s31_Analog_hall_magnetic SerialCallResponseASCII SerialEvent p15_HackingButtons SD SPIFlash USB\Keyboard\KeyboardLogout s32_touch s33_High_sensitive_voice VirtualColorMixer 05.Control CardInfo Datalogger Arrays ForLoopIteration DumpFile Files USB\Keyboard\KeyboardMessage USB\Keyboard\KeyboardReprogr am USB\Keyboard\KeyboardSerial s34_microphone_sound s35_Finger_measuring_heartbe at s36_Tracking USB\KeyboardAndMouseControl s37_Rotate_encode IfStatementConditional switchCase listfiles ReadWrite WIFI USB\Mouse\ButtonMouseControl USB\Mouse\JoystickMouseContro lUSBH\KeyboardController ConnectNoEncryption USBH\MouseController SernsorsKit_37in1 Smoothing 04.Communication ARDUINO USER MANUAL switchCase2 WhileStatementConditional 06.Sensors ADXL3xx Mar 20, 2015 ConnectWithWPA ScanNetworks s01_18b20 Page 12 of 17 Rev 1.01 Arduino 5.2 NuEdu-NUC240 Board The following table lists the Arduino samples which have been tested on NUC240 NuEdu board. 01.Basics AnalogReadSerial BareMinimum Blink DigitalReadSerial Fade Knock 07.Display WiFiWebServerr EEPROM s04_Button s05_Remote_emission barGraph RowColumnScanning 08.Strings eeprom_clear eeprom_read s06_Passive_Buzzer s07_Laser_transmit eeprom_write SPI s08_full_color_LED s09_Light_break LoopBack SPIFlashID Wire s10_two_color_LED s11_Buzzer CharacterAnalysis ReadAnalogVoltage 02.Digital StringAdditionOperator StringAppendOperator BlinkWithoutDelay Button StringCaseChanges StringCharacters Debounce DigitalInputPullup StringComparisonOperators StringConstructors master_writer programming_EEPROM StateChangeDetection toneKeyboard 03.Analog StringIndexOf StringLength slave_receiver slave_sender CAN_BUS master_reader s12_Analog_temperature s13_Digital_Temperature_Hu midity s14_full_color_LED s15_mercury_tilt_switch s16_Photoresistor s17_Relay receive_check s18_tilt_switch s19_mini_reed AnalogInput AnalogWriteMega StringStartsWithEndsWith StringSubstring receive_interrupt send s20_Remote_Receive s21_Joystick_PS2 Calibration Fading StringToInt StringToIntRGB 10.StarterKit set_mask_filter_recv OneWire s22_Linear_Hall s23_reed p02_SpaceshipInterface DS18x20_Temperature NuEdu_Basic s24_Flame s25_Magic_light_cup ASCIITable Dimmer p03_LoveOMeter p04_ColorMixingLamp ADCtoPWM Button s26_Digital_Temperature s27_two_color_LED Graph Midi p06_LightTheremin p07_Keyboard Buzzer EEPROM s28_Knock s29_Avoid MultiSerialMega PhysicalPixel p08_DigitalHourglass p09_MotorizedPinwheel IRremote LED s30_7_color_LED s31_Analog_hall_magnetic ReadASCIIString SerialCallResponse p10_Zoetrope p14_TweakTheArduinoLogo RGBLED SevenSegmentDisplay s32_touch s33_High_sensitive_voice SerialCallResponseASCII SerialEvent p15_HackingButtons SD SPIFlash USB\Keyboard\KeyboardLogout VirtualColorMixer 05.Control CardInfo Datalogger Arrays ForLoopIteration DumpFile Files USB\Keyboard\KeyboardMessage USB\Keyboard\KeyboardReprogra m USB\Keyboard\KeyboardSerial s34_microphone_sound s35_Finger_measuring_heartb eat s36_Tracking IfStatementConditional switchCase listfiles ReadWrite WIFI USB\Mouse\ButtonMouseControl USB\Mouse\JoystickMouseControl SernsorsKit_37in1 ConnectNoEncryption s01_18b20 ConnectWithWPA ScanNetworks s02_Shock s03_Analog_Hall Smoothing 04.Communication switchCase2 WhileStatementConditional 06.Sensors ADXL3xx Mar 20, 2015 s37_Rotate_encode USB\KeyboardAndMouseControl Page 13 of 17 Rev 1.01 ARDUINO USER MANUAL AnalogInOutSerial StringLengthTrim StringReplace Arduino 5.3 NuEdu-NANO130 Board The following table lists the Arduino samples which have been tested on NANO130 NuEdu board. ARDUINO USER MANUAL 01.Basics AnalogReadSerial BareMinimum Blink DigitalReadSerial Fade ReadAnalogVoltage 02.Digital BlinkWithoutDelay Button Debounce DigitalInputPullup StateChangeDetection toneKeyboard 03.Analog AnalogInOutSerial AnalogInput AnalogWriteMega Calibration Fading Smoothing 04.Communication ASCIITable Dimmer Graph Midi MultiSerialMega PhysicalPixel ReadASCIIString SerialCallResponse SerialCallResponseASCII SerialEvent VirtualColorMixer 05.Control Arrays ForLoopIteration IfStatementConditional switchCase switchCase2 WhileStatementConditional 06.Sensors ADXL3xx Mar 20, 2015 Knock 07.Display barGraph RowColumnScanning 08.Strings CharacterAnalysis StringAdditionOperator StringAppendOperator StringCaseChanges StringCharacters StringComparisonOperators StringConstructors StringIndexOf StringLength StringLengthTrim StringReplace StringStartsWithEndsWith StringSubstring StringToInt StringToIntRGB 10.StarterKit p02_SpaceshipInterface p03_LoveOMeter p04_ColorMixingLamp p06_LightTheremin p07_Keyboard p08_DigitalHourglass p09_MotorizedPinwheel p10_Zoetrope p14_TweakTheArduinoLogo p15_HackingButtons SD CardInfo Datalogger DumpFile Files listfiles ReadWrite WIFI ConnectNoEncryption ConnectWithWPA ScanNetworks WiFiWebServerr EEPROM eeprom_clear eeprom_read eeprom_write SPI LoopBack SPIFlashID Wire master_reader master_writer programming_EEPROM slave_receiver slave_sender OneWire DS18x20_Temperature NuEdu_Basic ADCtoPWM Button Buzzer EEPROM IRremote LED RGBLED SevenSegmentDisplay SPIFlash USB\Keyboard\KeyboardLogout USB\Keyboard\KeyboardMessage USB\Keyboard\KeyboardReprogram USB\Keyboard\KeyboardSerial USB\KeyboardAndMouseControl USB\Mouse\ButtonMouseControl USB\Mouse\JoystickMouseControl SernsorsKit_37in1 s01_18b20 s02_Shock s03_Analog_Hall s04_Button s05_Remote_emission s06_Passive_Buzzer s07_Laser_transmit s08_full_color_LED Page 14 of 17 s09_Light_break s10_two_color_LED s11_Buzzer s12_Analog_temperature s13_Digital_Temperature_Humidity s14_full_color_LED s15_mercury_tilt_switch s16_Photoresistor s17_Relay s18_tilt_switch s19_mini_reed s20_Remote_Receive s21_Joystick_PS2 s22_Linear_Hall s23_reed s24_Flame s25_Magic_light_cup s26_Digital_Temperature s27_two_color_LED s28_Knock s29_Avoid s30_7_color_LED s31_Analog_hall_magnetic s32_touch s33_High_sensitive_voice s34_microphone_sound s35_Finger_measuring_heartbeat s36_Tracking s37_Rotate_encode Rev 1.01 Arduino 5.4 NuEdu-UNO Board The following table lists the Arduino samples which have been tested on NUC131 NuEdu board. 01.Basics 07.Display EEPROM AnalogReadSerial barGraph eeprom_clear BareMinimum Blink RowColumnScanning 08.Strings DigitalReadSerial Fade CharacterAnalysis StringAdditionOperator eeprom_read eeprom_write SPI ReadAnalogVoltage 02.Digital s17_Relay s18_tilt_switch s19_mini_reed s20_Remote_Receive s21_Joystick_PS2 s22_Linear_Hall StringAppendOperator StringCaseChanges SPIFlashID Wire s23_reed s24_Flame BlinkWithoutDelay Button StringCharacters StringComparisonOperators master_reader master_writer s25_Magic_light_cup s26_Digital_Temperature Debounce DigitalInputPullup StringConstructors StringIndexOf programming_EEPROM slave_receiver s27_two_color_LED s28_Knock StateChangeDetection toneKeyboard 03.Analog StringLength StringLengthTrim slave_sender OneWire s29_Avoid s30_7_color_LED AnalogInOutSerial StringReplace StringStartsWithEndsWith DS18x20_Temperature NuEdu_Basic s31_Analog_hall_magnetic s32_touch AnalogInput AnalogWriteMega StringSubstring StringToInt ADCtoPWM Button s33_High_sensitive_voice s34_microphone_sound Calibration Fading StringToIntRGB 10.StarterKit Buzzer EEPROM s35_Finger_measuring_heartbeat s36_Tracking Smoothing 04.Communication p02_SpaceshipInterface p03_LoveOMeter IRremote LED s37_Rotate_encode ASCIITable Dimmer p04_ColorMixingLamp p06_LightTheremin RGBLED SevenSegmentDisplay Graph Midi p07_Keyboard p08_DigitalHourglass SPIFlash SernsorsKit_37in1 PhysicalPixel ReadASCIIString p09_MotorizedPinwheel s01_18b20 s02_Shock SerialCallResponse SerialCallResponseASCII p14_TweakTheArduinoLogo p15_HackingButtons SD SerialEvent VirtualColorMixer 05.Control p10_Zoetrope s03_Analog_Hall s04_Button CardInfo s05_Remote_emission s06_Passive_Buzzer Arrays Datalogger DumpFile s07_Laser_transmit s08_full_color_LED ForLoopIteration IfStatementConditional Files listfiles s09_Light_break s10_two_color_LED switchCase switchCase2 ReadWrite WiFi s11_Buzzer s12_Analog_temperature WhileStatementConditional 06.Sensors ConnectNoEncryption ConnectWithWPA s13_Digital_Temperature_Humidity s14_full_color_LED ADXL3xx Knock ScanNetworks WiFiWebServer s15_mercury_tilt_switch s16_Photoresistor Mar 20, 2015 ARDUINO USER MANUAL LoopBack Page 15 of 17 Rev 1.01 Arduino 6 REVISION HISTORY Date Revision Description 2014.11.10 1.00 1. Initially issued. 2015.3.20 1.01 1. Merged NuEdu-M451, NuEdu-NUC240, NuEduNANO130, NuEdu-UNO, and NuMaker-TRIO into the same platform group. 2. Updated sample list to include SernsorsKit_37in1 samples. ARDUINO USER MANUAL Mar 20, 2015 Page 16 of 17 Rev 1.01 Arduino 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”. Insecure usage includes, but is not limited to: equipment for surgical implementation, atomic energy control instruments, airplane or spaceship instruments, the control or operation of dynamic, brake or safety systems designed for vehicular use, traffic signal instruments, all types of safety devices, and other applications intended to support or sustain life. All Insecure Usage shall be made at customer’s risk, and in the event that third parties lay claims to Nuvoton as a result of customer’s Insecure Usage, customer shall indemnify the damages and liabilities thus incurred by Nuvoton. Mar 20, 2015 Page 17 of 17 Rev 1.01 ARDUINO USER MANUAL Important Notice