STMicroelectronics apresenta a família STM32WB que é o primeiro e único dual-core Cortex-M4 e Cortex-M0 + MCU no mercado certificado Bluetooth Low Energy v5.0 e 802.15.4. Para acompanhar a chegada desses componentes, também estamos lançando o STM32CubeMonRF, uma ferramenta de software para ajudar os desenvolvedores a testar e configurar seu rádio com mais eficiência. Também estamos lançando o P-NUCLEO-WB55, um pacote de desenvolvimento contendo uma placa Nucleo 64 clássica e um dongle USB. Ambos são fornecidos com o aplicativo de demonstração do microcontrolador,onde oferece uma experiência verdadeiramente única, pronta para uso.
Assista o webinar em: https://www.embarcados.com.br/webinars/webinar-stm32wb/
2. 14:00 Overview Bruno Montanari
STM32WB Portfolio
Overview
STM32CubeMX and
CubeIDE – first project
Stack Demos
BLE
Thread
Agenda
Time Speaker
Presentation
2
10. Bluetooth Mesh vs Thread
Bluetooth Mesh
• Based on Bluetooth 4.0 and later
• Broadcast type, flood the network with messages, no routing
• Shorter range, 3kbps application data rate, 1Mbps on-air bit-rate
• High power consumption
Thread
• IPv6-based using 802.15.4 MAC
• Routing table approach with network self healing
• Medium range, 40Kbps application data rate, 250Kbps on-air bit-rate
• Low power consumption
10
12. Software Development Tools
C/C++ Focus
12
STM32CubeMX
Configure & Generate Code
IDEs
Compile and Debug
STM32CubeProgrammer
STM32CubeMonitor
Program & Monitor
A complete flow, from configuration up to monitoring
FREE
IDE’s
8/29/2019
13. STM32 Nucleo key assets 13
Simply expose the whole STM32
portfolio to the communities
Flexible prototyping
Unlimited expansion
capabilities
20. Overview 20
• Choose ideal MCU and simply
configure
• Pinouts
• Clocks and oscillators
• Peripherals
• Low-power modes
• Middleware
• Helps choose the correct MCU for a given purpose
• Simulation provides an advantage in design phase
• Boosts development speed with a headstart
Application benefits
21. Prerequisites and settings 21
• STM32CubeMX needs Java RE
• Check release notes of the particular
version for additional requirements
• Multiplatform tool runs on Windows,
Linux and macOS
• After installation, hit Alt+S to configure
the updater – not only for the GUI but
also for Cube FW libraries
• Select SW library placement.
22. Updater 22
• Updates are accessible from
the Help menu
• The tool updater can detect
new releases of the tool and
the associated Cube library
• Use the libraries manager to
download new library
packages
23. MCU selector 23
• Find MCU by name …
• Quickly locate by Series and Lines
• … or application needs
• Package (pin count)
• RAM size
• NV memory requirements
• Embedded peripherals
• Number and type of interfaces
• Core and frequency
• Price
• Convenient links to documentation
• Export table to Excel file
24. Pin assignment 24
• Pinout from:
• Peripheral tree
• Manually
• Automatic signal
remapping
• Management of
dependencies between
peripherals and/or
middleware
(FatFS, USB …)
25. Pin assignment continued 25
Peripheral is not
available, all its
alternate pins are
assigned elsewhere
Click on the pin
to view
alternate
functions
Orange means the
peripheral is not
enabled, only the pin
is assigned
Freeze the signal
placement using
the pin icon
26. Peripheral and Middleware configuration 26
• Global view of used
peripherals and
middleware
• Highlight of
configuration errors
+ Not configured
ⱱ OK
Non-blocking problem
x Error
GPIO configuration
is considered
incorrect, but code
may be generated
Click to
configure DMA
Error in
configuration, code
generator will
display a warning
message
Configuration
is valid here
Quickly switch
pinout and
system view
27. Code generation
• Generate all the initialization code in C
• Generates project file for any supported
development toolchain
• User code can be added in dedicated sections
and will be kept upon regeneration
• Option to use the latest library version or keep
the same even if regenerating
31
Write your
code here to
keep option to
regenerate
the project
28. Clock configuration 32
• Immediate
display of all
clock values
• Active and
inactive clock
paths are
differentiated
• Management of
clock constraints
and features
29. Code generation project settings
• Name your project when
saving
• Browse for project location
• Pick the preferred toolchain
• Review the exact MCU type
and library version
33
30. Code generation options
• Library package
• Whole library or the necessary part may be
copied to the generated project folder
• Or keep the library in original place and refer
to it from all projects
• Generated files
• Each peripheral initialized in separate file or
in common source file
• Options for working with old files
• The option to keep user code intact is
here
• HAL settings
• Setting available pins to analog reduces
power consumption, but be careful to
explicitly select SWD/JTAG in pinout
• Full assert is useful for debugging
34
31. PCC (Power Consumption Calculator) 35
General PCC
configuration
panel
Sequence
configuration
Result
overview
37. CubeWB firmware
Different stacks required for different application types
BLE + Thread Static Concurrent mode project
Open MAC project
Thread projects
BLE projects
Zigbee 3.0 coming soon! – November 2019
38. CubeWB firmware
Encrypted radio stack binaries here HTML file details update procedure
Nucleo & Dongle boards come preloaded with the BLE stack
41. Free for commercial development
Based on Eclipse and GCC Open Source
projects
Multi Operating System Support
STM32CubeIDE 46
Free multi-platform development tool
macOS®
42. Debug features• Out-of-the-box STM32CubeIDE offers debug support for:
• SEGGER J-Link / J-Trace
• ST-Link
• OpenOCD (not bundled, useful for mbed devices)
• The debugger is capable of debugging single-core, multi-core and multi-
processor systems
• The debugger contains many powerful features including:
• Simple and advanced debug execution flow control
• Call stack display
• Simple/advanced visualisation variables/objects
• Simple/complex breakpoints and watchpoints
• Display of CPU core registers
• A powerful memory view
• Serial/Telnet/SSH terminal
• Advanced display of peripheral registers
• Live "real-time" variable watch view
• System analysis and real-time tracing (SWV)
• Instruction tracing support using ETM/ETB/MTB including trace start/stop triggers
• CPU fault analysis tool
• Kernel-aware debug support for many RTOSes
• The debugger is RTOS aware and has features for instruction tracing as well
as system analysis and real-time event- and data tracing, and also includes a
powerful script language for automation of advanced debug tasks.
• The Fault analyzer simplifies resolving Hard faults; (Bus, Usage Memory
management fault)
47
44. Hands-on : Launch STM32CubeIDE
• Set the desired workspace folder for all
the projects that shall be created by the
STM32CubeIDE
• Click on “Launch” button
• STM32CubeIDE Welcome Page
• Welcome Page enables the user to
quickly reach information regarding the
product, and how to use it
• Can be reached any time via the Help -
> Information Center
49
45. Hands-on : Creating the First Project
• Click on [Start new
STM32 project]
• Alternatively, go to:
• File -> New -> STM32
Project
50
46. Hands-on : Part selection 51
• After creating a New Project, it will
start a Target Selection window.
• Select an MCU/Board by entering
the part number (We have used the
PNucleo – WB55RG kit)
• Step 1: Here we enter “STM32WB55RG”
in the MCU Selector tab
• Step 2: Then select “STM32WB55RGVx”
• Step 3: Then click “Next”
2
1
3
47. Hands-on : Project Setup 52
• Enter the desired “Project Name”
• Enter “Next”
• The Firmware Library Setup window
shall appear
• *Pre-requisite* :
• STM32CubeMX and latest Firmware
package in the STM32CubeMX Repository
• OR
• Internet connection to Download and
install STM32CubeMX and the FW
package
• Once the *Pre-requisite* are addressed
• Then click “Finish”
• The below window appears, click “Yes”
STM32CubeMX
repository path
Firmware
package
version
48. Hands-on : STM32CubeMX Perspective 53
• Now the STM32CubeMX
perspective opens up
• You can also find the
“Project Explorer” view on
the left hand side
• A CubeMX Project (*.ioc)
is also created
• A default set of drivers,
startup, linker, main files
are created too
49. Hands-on: Pin Configuration 54
• In this example we are going to use one of the LEDs present on
the STM32G0 Nucleo board (connected to PA5 as seen in the
schematic below)
• Search for PB0 in the search window at the bottom
• Left-click PB0 and set it to GPIO_Output mode
50. Hands-on: Pin Configuration
• Configure PB0
as GPIO_Output
• Right click it and
select the Enter
User Label
• Change the
name to LD2.
55
1
2
3
51. Hands-on : Code Generation
• Go to Project Menu->Generate Code.
• Allow the tool to finish generating the
code.
• Open Main.c file to view the generated
code.
56
52. Hands-on : Add LED Blink and Build 57
• Step 1: Add the following user
codes in main() to toggle the
LED and increment some
variables a LED Toggle (1000ms
delay)
• Step 2: Build the project (Ctrl+B)
• Step 3: Do check the “Console”
for successful compilation and
linking
2 3
1
53. Hands-on : Debug Configuration 58
• Go to Run-> Debug As -
>STM32 MCU C/C++
Application
• Click on Debugger tab for more
settings
• Debug probe used in our case :
ST-LINK (ST-LINK GBD server)
• Debugging Interface : SWD
• Click OK to proceed.
54. Debug perspective 59
SFR view
Peripheral registers
contents are
displayed here
Fault Analyzer view
Display information if
a system fault occurs
Breakpoint view
Existing breakpoints are
shown or configured here
Variables and Expressions view
Run control toolbar
1. Restart
2. Skip all breakpoints
3. Resume
4. Suspend
5. Terminate
6. Disconnect
7. Step Into
8. Step Over
9. Step Return
10. Instruction Stepping mode
1 2 3 4 5 6 7 8 9 10
The STM32WB series is the first device in our portfolio of SoC radio devices.
It is also our first dual-core product with CortexM4 application MCU and a CortexM0+ radio MCU.
Even though it is placed under the wireless section, the STM32WB is both high performance and ultra low power capable. The STM32WB low power IP is taken from the STM32L4 ultra low power family devices.
As with our other products, the STM32WB has a 10 year production guarantee.
Mutli-Protocol:
- The STM32WB is Bluetooth 5.0 compliant with features that comply to the 5.0 specification.
- It has a 802.15.4 MAC layer which allows it to communicate through a Thread network, Zigbee network, or an 802.15.4 compliant proprietary network.
Dual-Core:
- 64MHz CortexM4 for application processing.
- 32MHz CortexM0+ for radio and security features.
Ultra-Low Power:
- Full control over the Cortex M4 run/low power modes
- The M0+ will stay asleep when not used and is off by default when the device is powered up.
- Low power peripherals can communicate with sensors while both cores are asleep.
Secure:
- The M0+ core has a customer key storage and PKA (public key acceleration hardware) hardware.
- This ensures that you can perform secure OTA updates without the need of CortexM4 being involved or another external microcontroller.
RF Tools (Comprehensive Ecosystem):
- This is one of the best features of the STM32WB that differentiates the WB from the competition.
- STM32CubeMx for configuration and code generation is already one of the key advantages to using the STM32 ecosystem.
- STM32CubeMontitor RF allows for very easy testing of the STM32WB. Developers can run the Bluetooth, Thread or Zigbee connections through scripts without the need to write application firmware.
- STM32CubeProgrammer allows you to easily download the M0+ communication stacks onto the STM32WB
In summary
Capability
Control
power consumption
Security
tools available
Set the WB apart from the competition.
As previously mentioned the STM32WB is multiprotocol with BLE 5.0 capability. Zigbee and Thread capability and the ability to use the 802.15.4 radio in what we call open MAC.
Looking at the stack summary, this provide a clear picture of each stack and the capabilities of concurrency.
As you can see BLE can be used with any 802.15.4 MAC stack as they both use different MAC hardware.
Both stacks use the same 2.4GHz radio so they need to timeshare the radio but this is taken care of by the CortexM0+ in the WB leaving the M4 core free for application purposes.
This is one of our advantages versus our competition as we can run FreeRTOS much easier in the STM32WB because of the dual cores AND specific hardware caching mechanisms in the WB.
The STM32WB Zigbee 3.0 stack will be fully certified and provided for free. Customer can use this stack free of charge on the STM32WB.
Customers using legacy Zigbee stacks can still maintain compatibility as you can use the Zigbee 3.0 stack alongside these legacy clusters and profiles in the STM32WB.
ST will be supporting Zigbee stack revisions R1 to R23 with the STM32WB.
Release of the Zigbee 3.0 stack will be late 2019.
Thread is the standard and OpenThread is the implementation. Customer will need to refer to Openthread examples when looking to implement a Thread network.
As we show in the thread block diagram the thread stack is located between the application layer and the 802.15.4 MAC inside the STM32WB.
It uses IPV6 packets in its communication.
We will look at some of the benefits of Thread in the coming slides.
Comparing Bluetooth Mesh and Thread we can see their differences.
Zigbee is similar to Thread in its datarate and mesh capabilities but use a different provisioning and network healing approach.
Bluetooth Mesh
Bluetooth mesh is an application solution that can be use on Bluetooth version 4.1 and later.
As seen in the picture here we can use the STM32WB and BlueNRG devices together in a Bluetooth mesh network.
It broadcasts all packets to everyone in the network until the intended receiver receives the packets.
This means it has much higher current consumption on all nodes as each node must listen and rebroadcast packets that are not intended for the node.
Application data rate is based on 1st hop with bigger packet sent. As the overhead is the same for each transaction this application data rate would be reduced with smaller payloads.
Thread (OpenThread)
Based on IP version 6 which allows it to create routing tables.
Nodes route packets accordingly to the routing table to reach the appropriate destination
The network is self healing meaning that nodes removed or added are automatically discovered and added to the network.
Lower power consumption than BLE mesh.
Application data rate is based on 1st hop with bigger packet sent. As the overhead is the same for each transaction this application data rate would be reduced with smaller payloads.
‘The WB Nucleo board includes the QFN68 variant of the STM32WB, buttons & LED’s, onboard PCB antenna, Arduino headers for adding sensor shields and the like, and an ST-LINK debugger.
The outer USB connector is the ST-LINK one that we will use. The inner USB connector is for USB applications running on the WB.
The Nucleo can also be run standalone with a CR2032 coin cell.
We used the Nucleo as a CubeMonitor sniffer, now let’s use the dongle!
We will invoke the USB bootloader to connect to the CubeProgrammer, and load the binary.
The embedded software package is a layered approach:
Low level: Hardware Abstraction Layer (HAL), with libraries and examples
Middleware level: Set of libraries with examples including RTOS, USB, TCP/IP … The figure highlights the libraries relevant for STM32G0: FAT File System, FreeRTOS and USB Power Delivery
Application level: Demonstrations for use on ST boards
Embedded software is delivered by series (STM32G0, STM32L4, …) and common modules are covered with fully portable APIs.
Embedded software initialization code can be generated through STM32CubeMX allowing the customer to remain focused on the core application code.
Hello, and welcome to this presentation of the STM32CubeMX Code Generation Tool. It covers the main features of this tool, which is used to configure and generate code, compile and debug, and estimate power consumption for the STM32 family of microcontrollers.
The STM32CubeMX application helps developers using STM32 microcontrollers through a user interface that guides the initial configuration of a firmware project.
It provides the means to configure pin assignments, the clock tree, integrated peripherals, and simulate the power consumption of the resulting project. It uses a rich library of data from the STM32 microcontroller portfolio.
The application is intended to ease the initial phase of development, by helping developers select the best product with regards to features and power.
Download the STM32CubeMX installer for free from the ST website and install it.
Then, set your preferences in the Settings menu:
One menu for the updater and library download (Alt+S),
The other menu for code generation and integration with development toolchains (Alt+P).
Once this setup is completed, a new project can be created.
If the internet connection is configured correctly, the tool can update itself as well as the code libraries used for generating the project workspaces.
Use the “Install new libraries” option (Alt+U) to download additional STM32Cube libraries, or retrieve older versions for interoperability reasons.
However, note that the STM32CubeMX tool is not tested with all historical library releases, and, new library releases may not work correctly with old tool versions.
The MCU selector window will come up after selecting the “New Project” option. If the user knows which MCU to use, it can be found quickly.
If not, the available products can be filtered based on the specific requirements.
The next step is to select the peripherals to be used and, where applicable, assign pins to their inputs and outputs.
Independent GPIOs can also be configured.
Signals are assigned to default pins, but they can be transferred to alternate locations, which are displayed by CTRL-clicking on the pin.
For example, when the I2C1 peripheral is enabled, the tool automatically assigns it to the default pins.
The tool automatically takes into account most bonds between the peripherals and software components it manages.
As more pins are reserved for their alternate functions, the choice of remaining configurations for other peripherals decreases.
The limitations are indicated by icon changes on other peripheral nodes.
Left-click on the pin to display its alternate functions.
Right-click on the pin to name or select the pin assignment.
If a pinout is selected without a particular peripheral enabled or if there is any other problem with the pinout, the pin turns orange instead of green.
The Configuration tab of the main window provides an overview of all the configurable hardware and software components that STM32CubeMX can help set up.
Each button with access to configuration options is displayed with a small icon indicating the configuration state.
The default state is not configured. Clicking on a button for a peripheral or middleware displays its configuration options.
Even when configured correctly, further modifications are possible.
Warning signs provide notifications about incorrect configurations, and the peripheral will not work if code is generated in this state.
Critical errors are represented by a red “X“ and the configuration must be modified to continue.
To add more peripherals and components, return to the Pinout tab.
Each middleware software component has options that are different, but they are all presented in a similar fashion, giving easy access to initialization options and providing informative descriptions.
When configuring a peripheral, the dialogue window shows basic parameters, dependencies and constraints. Simple drop-down menus are used when applicable.
Interrupts priorities can only be set in the “NVIC settings” tab. The peripheral window can only be used to enable or disable each interrupt.
The DMA settings tab contains all the parameters for DMA requests relevant for initialization, but run-time parameters (start address, …) are not managed here.
The GPIO settings tab is used to define GPIO parameters and features, pin filtering and the possibility to label each signal for easy identification.
The NVIC configuration panel is the central location with easy-to-understand overview of available and enabled interrupts, along with their priorities, is another advantage of STM32CubeMX. This window is used to enable interrupts for selected peripherals and to configure their priorities.
Select the tab for the corresponding DMA channel and click the “Add” button to add a DMA request for the specified peripherals. Verify all configuration options. Note that this configures a DMA channel, but does not fully describe a DMA transfer. This must be done in the application code.
When all inputs, outputs, and peripherals are configured, the code is ready to be generated.
First, check the settings in the Project menu of the main window.
One of the several supported development tools can be selected to take over the generated project, including toolchains from Keil, IAR, and Atollic.
User code must be kept between the constraints of the “USER CODE“ comment blocks in order for the initialization settings to be modified using STM32Cube MX without affecting the custom code.
See the next slides to see how to activate this option.
The clock configuration tab provides a schematic overview of the clock paths, along with all clock sources, dividers, and multipliers. Actual clock speeds are visible.
Active and enabled clock signals are highlighted in blue.
Drop-down menus and buttons serve to modify the actual clock configuration.
This window is available when saving the project (Save as...). The toolchain folder refers to where the workspace for the toolchain will be placed, not the actual toolchain application location. A limited version of this dialog window is also available using the Alt+P shortcut to display Project settings.
The STM32Cube HAL library may be associated with the project in various ways. Select the Copy option if the project should be migrated as a compact package or if there is a need to customize the library code. Keeping the library in the original location makes it easier to share the latest version of the library among several projects.
It can also generate the initialization code for all peripherals together in the stm32fxxx_hal_msp.c file, or generate one file per peripheral.
Options to back up or delete old files are a matter of the preferred workflow. Keep in mind that the options are tied to the re-generation function. This is also where the “keep user code when re-generating” option is enabled.
The “Set all free pins as analog” setting helps lower power consumption, but if the SWD/JTAG interface is not specifically selected in the Pinout tab, this option will disable the debug interface.
“Full assert” enables checking the parameters passed to the HAL functions, and may help reveal some bugs in the user code without an excessive debugging effort.
The Power Consumption Calculator is the fourth tab in the STM32CubeMX main window. The window is divided into several panes.
The general configuration pane summarizes the typical operating conditions and the MCU type currently selected.
The second pane displays the simulation sequence and its controls.
There is no button to execute the simulation; the results are available instantly.
ST’s Cube ecosystem for WB consists of 4 main components
CubeProgrammer to program & erase. We can connect via SWD or the various bootloader connections.. USART or USB for example.
We will dig deeper into this in one of the labs.
CubeProgrammer to configure option bytes. The command-line version is used to load secure stacks on the WB.
CubeMonitorRF uses a COM port and a specially programmed Nucleo or Dongle board to send Application Control Interface (ACI) commands to the BLE stack running on the M0+.
You can also run text-based scripts with sets of commands to create a heart-rate-monitor, for example.
You can also add a second board to do packet-error-rate testing, create a beacon, configure advertising and more!
It’s a super useful new tool and we will run some lab exercises to take a look!
All the standard peripheral examples that you would expect from an STM32.
Also, lots of projects for BLE, Thread, BLE+Thread Static Concurrent modes, the OpenMAC full-featured and reduced-feature device examples, FreeRTOS and USB.
All examples run out of the box on IAR, Keil and GCC.
Again, Zigbee is coming soon!
Full source code for the upper stack application-layer firmware that runs on the M4.
The boards come preloaded with the BLE radio stack. For other protocols, other stacks have to be loaded securely.
These folders are associated with different radio stacks, detailed in the next slide.
The “CoPro Wireless Binaries” folder contains the encrypted radio stack binaries.
The update procedure is detailed in the HTML file.
We will detail this a bit later today.
On the new Nucleo boards we use a circuit using transistor to drive the LED which is shared with the Arduino connector. This comes from some issues that we met with some shield where the LED was impacting the SPI communciation. Using a transistor permits to isolate the LED and to get a cleaner SPI signal when the SPI alternate function is used for PA5.
The circuit to drive the LD4 on the Nucleo board is using a transistor but the IOs of the STM32G0 can source and sink up at least 15 mA (Absolute max rating for a control IO) where you can sink and source LED by the IO only without the need for a transistor.