Getting started with STM32Nucleo Boards Mirko Falchetto February 27 th, 2017
Agenda 2 0 The IoT Opportunities 1 Introduction to the STM32 Nucleo Boards 2 Introduction to the MBED Development Environment 3 A Primer: Board Setup & Demo Examples on MBED
IoT Opportunities 3 Smart Home and City Smart Industry Smart Me Energy saving Security Comfort Smart Manufacturing Sport Wellness Health care
ST blocks for IoT 4 Sensing Connectivity Power Environmental Motion Microphones Sub-GHz BT, BLE Wifi Wireless charging Bat. Chargers Smart On/Off Analog Signal conditioning Interfaces Bio-sensing MCU Low-power Sensor fusion Security Authentication Contactless payment
ST Augmenting the IoT Development 5 Hardware Bricks Software Bricks Cloud Services Sense Connect Translate Actuate Power Process Application Examples Middleware Libraries Board Support Package Hardware Abstraction Layer Various Dev. Environment
Agenda 6 0 The IoT Opportunities 1 Introduction to the STM32 Nucleo Boards 2 Introduction to the MBED Development Environment 3 A Primer: Board Setup & Demo Examples on MBED
STM32 Nucleo Development Board 7 Based on ST s 32-bit ARM Cortex-M based STM32 microprocessors A Boards with 1 MCU and hardware to program/debug Two connectors to connect to companion chips boards Flexible board power supply through USB or external source Integrated Debugging and programming probe (ST-Link v2) Arduino UNO extension connectors easy access to addons (*) STM32 Microcontroller Morpho extension headers: Direct access to all STM32 I/Os For all STM32 families >60K Boards sold complete product range from ultra-low power to high-performance (*) thanks to the electrical compatibility it can be used as a shield for Arduino UNO R3 or similar
Nucleo Expansion Boards leverage ST Breadth and Depth Product Portfolio 9 MEMS & Sensors Microcontroller Power Discrete & Modules Automotive Analog & Mixed Signal ICs Secure MCU Industrial Analog ASSP Imaging RF Connectivity Memory Power Conversion Digital Consumer & ASICs A unique portfolio with all the key technologies and products Increasing semiconductor content per application Sense Power Interact Connect Move
STM32 Nucleo Expansion Boards How to address the Functional Needs 10 What do you want to do? What you need Board Process Ultra Low power STM32 L0 Sense motion, pressure, humidity, light, gas, location Connect wireless or wired Ultra Low power Mainstream Mixed signal +DSP High performance High performance + DSP Motion Sensors Environmental Sensors Proximity Sensors OpAmp Bluetooth Low Energy Wi-Fi Sub-GHz radio NFC STM32 L1 STM32 F1 STM32 F3 STM32 F2 STM32 F4 (F7 Planned) Motion + Environmental Motion + Environmental FlightSense OpAmp BlueNRG SPIRIT1 M24SR Translate Motor Driver xspin (easyspin, dspin,..) Move/Activate Audio amplifier Audio-Out Audio Microphone Audio-in Power Energy management & Battery Energy management (EnFILM)
STM32 Nucleo Expansion Boards 11 Boards with additional functionality that can be plugged on top of the STM32 Nucleo development board directly or stacked on another expansion board. Connect Power Move / Actuate Translate Sense Motion MEMS sensors Example: X-NUCLEO-IKS01A2 LSM303AGR LSM6DSL Environmental sensors DIL24 support for new devices LPS22HB HTS221 www.st.com/x-nucleo
STM32 Nucleo Expansion Board Portfolio 13 Sense Connect Power / drive Motion and environment sensors Proximity sensors Order Code (*) Description Key products LIS3MDL, LSM6DS0, HTS221, X-NUCLEO-IKS01A1 LPS25HB Motion MEMS & environmental sensors LSM303AGR, LSM6DSL, HTS221, X-NUCLEO-IKS01A2 LPS22HB X-NUCLEO-6180XA1 Proximity, gesture and ambient light sensor expansion board VL6180X X-NUCLEO-53L0A1 Ranging and gesture sensor expansion board VL53L0X Microphone X-NUCLEO-CCA02M1 Digital MEMS microphone expansion board Bluetooth low energy 4.1 X-NUCLEO-IDB04A1 X-NUCLEO-IDB05A1 Bluetooth Low Energy module expansion board MP34DT01-M, STPS160A, ESDA7P60-1U1M, USBLC6-2SC6 SPBTLE-RF, M95640-R SPBTLE-RF, M95640-R Wi-Fi X-NUCLEO-IDW01M1 Wi-Fi expansion board SPWF01SA.11, STLQ50C25R Sub-GHz radio NFC Battery and energy management X-NUCLEO-IDS01A4 868 MHz RF expansion board SPSGRF-868, M95640-R X-NUCLEO-IDS01A5 915 MHz RF expansion board SPSGRF-915, M95640-R X-NUCLEO-NFC01A1 X-NUCLEO-NFC02A1 Dynamic NFC Tag expansion board M24SR M24LR X-NUCLEO-NFC03A1 NFC card reader expansion board CR95HF X-NUCLEO-IPS02A1 24V Intelligent power switch expansion board VPS2535H LED lighting X-NUCLEO-LED61A1 DC-DC LED driver expansion board LED6001, STL3N10F7, STL8N10LF3, STPS2L60A, BAS70KFILM, ESDAULC5-1BF4, SMM4F33A-TR (*) Refer to www.st.com for STM32 Nucleo and X-CUBE related
MEMS and environmental sensors expansion board Hardware Overview (1/2) 15 Hardware Description The X-NUCLEO-IKS01A1 is a MEMS motion and environmental sensor evaluation board system. It is compatible with the Arduino UNO R3 connector layout, and is designed around ST s latest sensors. Key Product on board LSM6DS0: MEMS 3D accelerometer (±2/±4/±8 g) + 3D gyroscope (±245/±500/±2000 dps) LIS3MDL: MEMS 3D magnetometer (±4/ ±8/ ±12/ 16 gauss) LPS25H(B): MEMS pressure sensor, 260-1260 hpa absolute digital output barometer HTS221: capacitive digital relative humidity and temperature DIL 24-pin: socket available for additional MEMS adapters and other sensors (UV index) HTS221 LPS25H LSM6DS0 LIS3MDL DIL 24-pin ST Morpho connector** Arduino UNO R3 connector ** Connector for the STM32 Nucleo Board Order Code: X-NUCLEO-IKS01A1 Unit Price (US$)*: 15.5 (*) Suggested Resale Price per unit (USD) for BUDGETARY USE ONLY
MEMS and environmental sensors expansion board Hardware Overview (2/2) 16 Key Features The X-NUCLEO-IKS01A1 is a MEMS inertial and environmental sensor evaluation board system. All sensor sensors are connected on a single I2C bus Sensor I²C address selection Each sensor has separate power supply lines allowing power consumption measurement Sensor disconnection (disconnect the I²C bus as well as the power supply) Interrupt and DRDY signals from sensors DIL24 socket (Compatible to STEVAL-MKI***V* MEMS adapter boards) * is used as a wildcard character for related part number Order Code: X-NUCLEO-IKS01A1 Unit Price (US$)*: 15.5 (*) Suggested Resale Price per unit (USD) for BUDGETARY USE ONLY
Agenda 17 0 The IoT Opportunities 1 Introduction to the STM32 Nucleo Boards 2 Introduction to the MBED Development Environment 3 A Primer: Board Setup & Demo Examples on MBED
STM32 ARM mbed 18 ST Support of ARM mbed ARM mbed (www.mbed.com) is a platform developed by ARM to support easy and quick development of applications on Cortex M-series based microcontrollers Two main categories: Platforms ST Nucleo boards Components ST Expansion boards (19) Online compiler for easy-to-use development and fast prototyping
mbed2.0 expansion boards 19 Sensors and analog Wireless communication Motor drive X-NUCLEO-IDB04A1 BLUETOOTH LOW ENERGY X-NUCLEO-IHM01A1 STEPPER MOTOR DRIVER Others X-NUCLEO-IKS01A1 MOTION MEMS AND ENVIRONMENTAL SENSORS X-NUCLEO-6180XA1 PROXIMITY AND AMBIENT LIGHT SENSOR X-NUCLEO-IKA01A1 MULTIFUNCTIONAL EXPANSION BOARD BASED ON OPERATIONAL AMPLIFIERS X-NUCLEO-IDB05A1 BLUETOOTH LOW ENERGY X-NUCLEO-NFC01A1 DYNAMIC NFC TAG IoT X-NUCLEO-IDW01M1 Wi-Fi EXPANSION BOARD X-NUCLEO-IHM02A1 TWO AXIS STEPPER MOTOR DRIVER X-NUCLEO-IHM03A1 HIGH POWER STEPPER MOTOR DRIVER X-NUCLEO-IHM05A1 BIPOLAR STEPPER MOTOR DRIVER X-NUCLEO-PLC01A1 PROGRAMMABLE LOGIC CONTROLLER X-NUCLEO-LED61A1 LED DRIVER X-NUCLEO-IHM04A1 DUAL BRUSH DC MOTOR DRIVER X-NUCLEO-IPS02A1 INTELLIGENT POWER SWITCH X-NUCLEO-IHM06A1 LOW VOLTAGE STEPPER MOTOR DRIVER
https://developer.mbed.org 20
mbed for developers 21 Go to www.mbed.com developer.mbed.org Log In/Signup Hardware Boards STMicroelectronics NUCLEO-F401RE
STMicroelectronics platforms 22
mbed page for STM32Nucleo F401 23
Something to install PC drivers 24 ST-Link/V2-1 driver
After PC driver installation 25 connect NUCLEO board to PC via USB drag-and-drop binary file on virtual storage device to program the board
Agenda 27 0 The IoT Opportunities 1 Introduction to the STM32 Nucleo Boards 2 Introduction to the MBED Development Environment 3 A Primer: Board Setup & Demo Examples on MBED
Good Design on Programming Embedded Devices Don't optimize your code till you know you really need to.. Don t think you are smarter than the compiler.. 28 When you program "without wasting any resources", do you consider your time a resource? Write your code so it's reliable, readable and maintainable first.. Use a KISS* Methodology and avoid code duplications at all costs.. * U.S. Navy 1960 Keep it simple & stupid -> Keep it small & simple Define simple clear orthogonal API s and keep under the carpet the garbage Don t verbosely comment your code If you comment every single line of code probably you re code is not that clear and not that good designed.. Use C Language in a C++ way (OO Programming).. be ready to use (few) global variables but encapsulate them wherever possible Abstract datatypes and use preprocessor macros to improve code readability
Things to consider on Programming Embedded Devices (On errors) Embedded systems usually will stop to work in unexpected ways, not just make it go slow.. Stack usually stack size is small. Stack problems cause some of the most insidious defects Heap usually smaller heap sizes : avoid unwarranted memory allocation. Fragmentation quickly becomes an issue. When malloc or new [] returns NULL, do you check for it and what do you do? Most MCU embedded systems do not use dynamic memory for these reasons. 29 Hardware interrupts - handle these in a safe and timely manner. Use only safe re-entrant code on your interrupt routines (no STD C lib, printf.. etc.). Assembly Language - almost always source of premature optimization. As an exercise, write a small method in hand crafted assembly (from scratch). Do the same in C. Measure the performance. I bet the C will be faster.. And I know it will be more readable, maintainable and extendable. But In case be prepared to inspect assembly code generated by the compiler if really needed
1 st mbed Program: Led Blinking 30 Connect your NUCLEO-F401RE to your PC via USB New New Program Save As
1 st mbed Program: Led Blinking 31 Practice 1 Change the frequency of blinking Practice 2 Change the frequency of blinking using a timer (i.e. a ticker)
Activity 2: NUCLEO + MEMS 35 1 Plug the 2 boards X-NUCLEO-IKS01A1 + NUCLEO-F401RE 2 Go to mbed.org and select: Components Sensors Motion X-NUCLEO-IKS01A1 Import the program HelloWorld_IKS01A1 into your mbed online compiler Do not check Update this program and libraries to the latest revision Compile the program and flash it on the NUCLEO board
Activity 2: NUCLEO + MEMS 36 3 4 5 6 Install a Serial Terminal on your PC Tera Term on Windows: http://tera-term.en.lo4d.com minicom on Linux: http://fossies.org/linux/misc/minicom-2.7.tar.gz CoolTerm on OS: https://www.macupdate.com/app/mac/31352/coolterm/download Plug the board, run the terminal and open a connection COMx port in Windows ttyacmx in Linux usbmodemxxxx in OS X Setup Serial port: Baud rate: 9600 Data: 8 bit Parity: none Stop: 1 bit Flow control: none Terminal: Receive New Line: AUTO Reset the board to start displaying values on the screen
Thanks! 42 Questions? Mirko Falchetto Advanced System Technology Embedded Analytics Research Platform Sr. SW System Engineer ST Microelectronics S.r.l. 20010 Cornaredo (MI), Italy Via Tolomeo, 1 Tel: +39 02 93519 307 Fax: +39 02 93519 376 mirko.falchetto@st.com