STMicroelectronics STM32CubeG0 User Manual
광고
광고
UM2308
User manual
STM32CubeG0 Nucleo demonstration firmware
Introduction
STM32Cube™ is an STMicroelectronics original initiative to make developers’ lives easier by reducing development effort, time and cost. STM32Cube covers the whole STM32 portfolio.
The STM32Cube includes:
• STM32CubeMX, a graphical software configuration tool that allows the generation of C initialization code using graphical wizards.
• A comprehensive embedded software platform, delivered per Series (such as
STM32CubeG0 for STM32G0 Series)
– The STM32Cube HAL, STM32 abstraction layer embedded software ensuring maximized portability across the STM32 portfolio
– The Low-Layer APIs (LL) offering a fast light-weight expert-oriented layer which is closer to the hardware than the HAL. LL APIs are available only for a set of peripherals
– A consistent set of middleware components such as FAT file system, RTOS, USB PD
– All embedded software utilities, delivered with a full set of examples
The STM32CubeG0 Nucleo demonstration firmware is built around the STM32Cube hardware abstraction layer (HAL) and low-layer (LL) APIs, and board support package
(BSP) components, and uses almost the whole STM32 capability to load and display full color bitmaps from a microSD™ card.
November 2018 UM2308 Rev 2 1/18 www.st.com
1
Contents
Contents
UM2308
STM32CubeG0 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Getting started with the demonstration . . . . . . . . . . . . . . . . . . . . . . . . . 6
NUCLEO-G071RB Nucleo board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
STM32 Nucleo board configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Assembling the Adafruit shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Demonstration firmware package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
STM32 Nucleo board BSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Functional description of the demonstration . . . . . . . . . . . . . . . . . . . . 12
Programming firmware application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2/18 UM2308 Rev 2
UM2308
List of tables
List of tables
UM2308 Rev 2 3/18
3
List of figures
List of figures
UM2308
4/18 UM2308 Rev 2
UM2308
1 STM32CubeG0 main features
STM32CubeG0 main features
STM32CubeG0 gathers, in a single package, all the generic embedded software components, required to develop an application on STM32G0 microcontrollers. In line with the STMCube initiative, this set of components is highly portable, not only to the STM32G0
Series but also to other STM32 Series.
STM32CubeG0 is fully compatible with the STM32CubeMX code generator that allows to generate initialization code.
The package includes a Driver layer (HAL) proposing a set of abstraction services and a low-level hardware layer (LL) proposing a set of register level functions, together with an extensive set of examples running on STMicroelectronics boards. HAL is available in opensource BSD license for user convenience.
STM32CubeG0 package also contains a set of middleware components with the corresponding examples. They come in free user-friendly license terms:
• USB PD Core and Devices
• CMSIS-RTOS implementation with FreeRTOS™ open source solution
• FAT file system based on open source FatFS solution
Several applications and demonstrations implementing all these middleware components are also provided in the STM32CubeG0 package.
The block diagram of STM32Cube is shown in
Figure 1: STM32CubeG0 firmware components
Figure 1. STM32CubeG0 firmware components
(YDOXDWLRQ
ERDUGV
'LVFRYHU\
ERDUGV
$SSOLFDWLRQOHYHOGHPRQVWUDWLRQV
6701XFOHR
ERDUGV
'HGLFDWHG
ERDUGV
8VHU
DSSOLFDWLRQ
86%3'
0LGGOHZDUHOHYHO
)$7
ILOHV\VWHP
%RDUG6XSSRUW3DFNDJH%63
+$/DQG//$3,V
7KHVHWRIPLGGOHZDUHFRPSRQHQWVGHSHQGVRQWKHSURGXFW6HULHV
/RZOD\HU$3,V//
8WLOLWLHV
5726
&06,6
8WLOLWLHV
+DUGZDUHDEVWUDFWLRQOD\HU$3,V
+$/
06Y9
UM2308 Rev 2 5/18
17
Getting started with the demonstration
2 Getting started with the demonstration
UM2308
The hardware requirements to start the demonstration application are the following:
• NUCLEO-G071RB Nucleo board
• Adafruit 1.8" TFT shield with joystick and microSD (reference ID: 802)
• one 'USB Type A to Mini-B' cable to power up the STM32 Nucleo board from the USB
ST-LINK (USB connector CN2)
• a standard capacity SD card (SDSC up to 4 Gbytes) or a high capacity SD card (HDSC up to 32 Gbytes).
The STM32 Nucleo board is a low-cost and easy-to-use development kit, to evaluate and start quickly some development with the Arm ®(a) 32-bit Cortex ® -M microcontrollers of the
shows the NUCLEO-G071RB and its package. Before installing and using the product, accept the Evaluation Product License Agreement available at www.st.com/epla.
For more information on the STM32 Nucleo boards visit www.st.com/stm32nucleo.
Figure 2. NUCLEO-G071RB Nucleo board
6/18 a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
UM2308 Rev 2
UM2308
2.1.2
Getting started with the demonstration
Adafruit 1.8” TFT shield
The STM32 Nucleo board supports Arduino™ connectivity.
This Adafruit 1.8" TFT shield may be found on the Adafruit website (reference ID 802) with the following features (see
):
• one 1.8” 128x160 TFT color display
• one microSD card interface slot
• one 5-way joystick navigation switch (left, right, up, down and select)
Figure 3. Adafruit 1.8” TFT shield
2.2.1
To start using the Adafruit 1.8” TFT shield with the STM32 Nucleo board, follow the recommendations in
in addition to gather the hardware.
STM32 Nucleo board configuration
Check the positions of the jumpers on the STM32 Nucleo board, as follows:
• JP1 OFF
• JP2 ON: PIN1 and PIN2 connected (ST-LINK configuration)
• JP3 (I
DD
) ON
UM2308 Rev 2 7/18
17
Getting started with the demonstration UM2308
The Adafruit TFT shield comes with all the surface parts soldered . User can install the headers following the next steps:
• Cut the breakaway header strip into sections, to fit the holes on the edge of the shield: two sections of six pins and two other sections of eight pins are needed.
• To align the header strips for soldering, insert them (long pins down) into the headers of the STM32 Nucleo board using the connectors CN7, CN8, CN10 and CN12.
• Place the shield over the header strips, so that the short pins stick up through the holes.
• Solder on each pin of the header onto the shield PCB to ensure good electrical contact.
The sequence is shown in Figure 4
.
Figure 4. Assembling the Adafruit 1.8” TFT shield
8/18 UM2308 Rev 2
UM2308 Demonstration firmware package
The demonstration Adafruit_LCD_1_8_SD_Joystick is provided within the STM32CubeG0 firmware package, as shown in
.
Figure 5. Folder structure
3.2
The demonstration sources are located in the project folder of the STM32Cube package for the NUCLEO-G071RB Nucleo board. The sources are divided into five groups, described as follows:
1.
Binary: demonstration binary file in Hex format
2. Media: the media files (*.bmp) required to run the demonstration are available under the firmware package Utilities\Media\Pictures folder
3. Inc: contains the demonstration header files
4. Src: contains the demonstration source files
5. Project settings: a folder per toolchain containing the project settings and the linker files
STM32 Nucleo board BSP
The
Figure 6: Nucleo BSP architecture show the BSP architecture. For each board, a set of
drivers for button, LED and joystick is available within the _nucleo.c/.h
files, implementing the board capabilities and the bus-link mechanism.
UM2308 Rev 2 9/18
17
Demonstration firmware package
Figure 6. Nucleo BSP architecture
UM2308
10/18 UM2308 Rev 2
UM2308 Demonstration firmware package
3.2.1 Joystick
The 5-way joystick on the shield is based on a resistor trick, to permit all the switches to share one analog pin. Each movement of the joystick control connects a different resistor and results in a different voltage reading.
The ADC peripheral is configured within the stm32g0xx_nucleo.c/.h
driver, to get analog voltage values through the analog I/O pin 3.
The BSP_JOY_GetState() function reads the analog pin and compares the result with five different ranges, to determine in which direction (if any) the stick has been moved (left, right, up, down, select).
3.2.2 LCD
The LCD available on the Adafruit 1.8" TFT shield uses 4-wire SPI to communicate with the
STM32G071RBT6 chipset (Digital I/O pins 13, 12, 11 and 10) and has its own pixeladdressable frame buffer to display text, shapes, lines, pixels and others.
The SPI peripheral is configured within the stm32g0xx_nucleo.c/.h
driver, which contains also the SPI bus-link mechanism and I/O operations.
The LCD is controlled by a dedicated BSP LCD driver stm32_adafruit_lcd.c/.h, which uses the st7735 component that exports the LCD I/O operations needed for its process.
3.2.3 microSD
The microSD slot available on the Adafruit 1.8" TFT shield uses 4-wire SPI to communicate with the STM32G071RBT6 chipset (Digital I/O pins 13, 12, 11 and 10).
The SPI peripheral is configured within the stm32g0xx_nucleo.c/.h
driver which contains also the SPI bus-link mechanism and I/O operations.
The microSD is controlled by a dedicated BSP SD driver stm32_adafruit_sd.c/.h
, which exports in a generic way the SD I/O operations needed for its process.
UM2308 Rev 2 11/18
17
Functional description of the demonstration
4 Functional description of the demonstration
UM2308
This demonstration application shows how to use the STM32CubeG0 firmware package with the NUCLEO-G071RB board and the Adafruit 1.8” TFT shield, to display a 128x160pixel, full-color bitmap from a microSD card using the FatFS file system.
To start with this demonstration application, the user has to copy the provided 128x160-pixel bitmap pictures, available within the firmware package under “\Media” folder, to the root directory of a FAT formatted microSD card and insert the microSD card into the Adafruit shield microSD holder.
Note that the microSD card can have a storage capacity up to 4 Gbytes (SDSC) and that the bitmap images must have the properties detailed as in
Table 1. Bitmap image properties
Dimensions 128 x 160
Width
Height
Bit depth
Item type
Name
128 pixels
160 pixels
16
BMP file
Must not exceed 11 characters (including bmp extension).
Once started, the application checks the availability of the Adafruit 1.8" TFT shield on top of the STM32 Nucleo board. This is done by reading the state of the I/O PC.13 pin (mapped to the joystick available on the shield). If the state of PB.00 is high then the shield is available.
If the Adafruit 1.8" TFT shield is not available, the LED4 blinks with a frequency of ~1Hz. A first press on the user button makes the LED4 blinking with a frequency of ~5Hz. At the second press, the LED4 blinks with a frequency of ~10Hz and at the third press, the LED4 blinks with a frequency of ~5Hz. The described process is done in an infinite loop.
If the Adafruit 1.8" TFT shield is available, the LED4 is turned ON, because it is sharing the same pin with the SPI CLK signal, used to communicate with the LCD and microSD available on the shield.
A menu is displayed on Adafruit 1.8" TFT describing the demonstration application, as
shown in Figure 7: Demonstration application menu on NUCLEO-G071RB .
Figure 7. Demonstration application menu on NUCLEO-G071RB
12/18 UM2308 Rev 2
UM2308 Functional description of the demonstration
User has to follow the instructions below:
•
Press the joystick DOWN to keep displaying the menu (see Figure 8: Reading the
)
• Choose one of the available display modes (manual or automatic) using the joystick button:
– Automatic mode : by pressing joystick DOWN
The bitmap images available on the microSD card are displayed sequentially in a forever loop.
– Manual mode : by pressing joystick UP
The bitmap images available on the microSD card are displayed by pressing joystick right to display next image, or joystick left to display the previous one.
Keeping the joystick pressed in select for ~1s, switches the display mode from manual to automatic.
Figure 8. Reading the Adafruit shield joystick
Note that the application manages some errors (refer to
), that can occur during the access to the microSD card to load the bitmap images:
• If the microSD card is not FAT formatted, a message is displayed on TFT. In this case, format the microSD card and put into its root directory the *.bmp files available within the firmware package under \Media folder.
• If the format of the files stored on the microSD card is not bitmap, an error message is displayed on TFT, mentioning that the format is not supported. User has to check carefully that the files, available under the microSD card root directory, comply with the above described bitmap properties.
The
shows the demonstration running.
UM2308 Rev 2 13/18
17
Functional description of the demonstration
Figure 9. Demonstration application error messages
UM2308
Figure 10. Demonstration running
14/18 UM2308 Rev 2
UM2308
4.1
Functional description of the demonstration
Programming firmware application
To program the STM32 Nucleo board with the demonstration application, proceed as follows:
1.
Install the preferred Integrated Development Environment (IDE)
2. Install the ST-LINK/V2.1 driver available on ST website.
There are two ways of programming the STM32 Nucleo board:
• Method 1:
Using the preferred in-system programming tool and depending on the STM32 Nucleo board:
– upload the STM32CubeG0_Demo_STM32G071RB_Nucleo.hex from the firmware package available under: Projects\STM32G071RB-
Nucleo\Demonstrations\Binary
• Method 2:
Choose one of the three supported tool chains (IAR™ / Keil ® / AC6 ® ) and follow the steps below:
– Open the application folder either:
Projects\SM32G071RB-Nucleo\Demonstrations\Adafruit_LCD_1_8_SD_Joystick
– Chose the desired IDE project (EWARM for IAR, MDK-ARM for Keil or
SW4STM32 for AC6)
– Double click on the project file (for example Project.eww for EWARM)
– Rebuild all files: go to Project and select Rebuild all
– Load the project image: go to Project and select Debug
– Run the program: go to Debug and select Go .
The demonstration software as well as other software examples that allow user to discover the STM32 microcontroller features, are available on ST website at www.st.com/stm32nucleo.
UM2308 Rev 2 15/18
17
FAQs
5 FAQs
UM2308
How can I use this application to display my own images?
Use any image editing tool and crop/resize the image to be no larger than 160 pixels high and 128 pixels wide. Save it as a 16-bit color BMP format file.
Can I display more bitmap files?
Yes, it is possible. Display more pictures, by copying them under the microSD root directory.
Modify the value of the MAX_BMP_FILES constant in the #define directive with the desired number of files. In this case, the user must fine-tune the _FS_LOCK value, defining the number of files that can be opened simultaneously, under “ffconf.h” the FatFS configuration file.
Can I store the bitmap files in a folder different from the root directory of the microSD?
If the bitmap files are stored in a folder different from the root directory, they cannot be accessed by the demonstration application. The “File type not supported” error message is displayed on the LCD.
To make it work, add the new directory path within f_open() and f_opendir() FatFS APIs calls under the fatfs_storage.c file.
16/18 UM2308 Rev 2
UM2308
Date
26-Sep-2018
20-Nov-2018
Revision
Table 2. Document revision history
Changes
1
2
Initial version
Updated
to STM32Cube standard
Revision history
UM2308 Rev 2 17/18
17
UM2308
IMPORTANT NOTICE – PLEASE READ CAREFULLY
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers’ products.
No license, express or implied, to any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
© 2018 STMicroelectronics – All rights reserved
18/18 UM2308 Rev 2
다운로드
광고