-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started
This project is originally developed using STM32CubeMX for code initialization and System Workbench for STM32 for coding, which offer free licenses for all STM32 microcontrollers and are fully compatible with Windows, Mac and Linux.
In order to use the libraries and examples provided in this page, it is necessary to have both softwares fully installed in your computer. For further information about each software, refer to the STM32CubeMX documentation page and System Workbench for STM32 documentation page.
Thle Digital Clock library uses the 4ilo/HD44780-Stm32HAL LCD libraries lcd.c and lcd.h properly revised to fit the application, which are already included in the library files. It also uses LCDKPD4NUCLEO_F401 keypad libraries lcdkpd4stm32f401.c and lcdkpd4stm32f401.h properly modified to fit the application, which are also already included in the library files. Furthermore, ST HAL library is necessary for GPIO, ADC and RTC initialization, and the correct pin and peripheral initialization using the STM32CubeMX software and also must be properly added and configured for use in System Workbench for STM32. The procedures are described below for the NUCLEO-F103RB Board and the LCD Shield, but apply to any NUCLEO Board. When necessary, the steps must be altered for the specific devices used.
After opening the STMCubeMX software, click on the ACCESS TO BOARD SELECTOR button, as shown below.
Type the NUCLEO-F103RB board name in the upper left corner part number. The corresponding board will appear on the lower right corner.
Click on the Start Project button in the upper right corner, as shown below.
A pop-up will appear asking for the default peripheral initialization for the selected board. Click Yes to automatically perform clock, debug interface and on-board GPIO configuration for the NUCLEO-F103RB.
A new screen will open with the microcontroller dysplayed on the right and a menu on the left. The first step will be the pin functionality selection. As an example, we will configure PA0 as an analog input pin. First, click on the pin displayed on the microcontroller image.
A pop-up menu will appear with the possible attributions to the selected pin. Select AD1_IN0, which corresponds to connect the pin to an Analog to Digital Converter input, more specifically, the input 0 from the ADC1 peripheral.
Repeat the process for the following pins and corresponding attributions:
| Pin | Attributions |
|---|---|
PA8 |
GPIO_Output |
PA9 |
GPIO_Output |
PB4 |
GPIO_Output |
PB5 |
GPIO_Output |
PB6 |
GPIO_Output |
PB10 |
GPIO_Output |
PC7 |
GPIO_Output |
Click on Timers → RTC and make the same configuration as shown.
Enable the RTC alarm interrupt through EXTI line 17.
Then, click on the upper tab named Clock Configuration and check the highlighted fields to correspond the selections and values.
Click on Project Manager and insert the name of the project in the first field, select the destination folder for the project in the second field and select the Toolchain IDE as SW4STM32.
Click on Code Generator and make sure the select items correspond to the image below.
Click on GENERATE CODE.
Click on Open Project and the System Workbench for STM32 software will open and import the corresponding project from STM32CubeMX.
Download the library files from the link and extract the library folder.
In the example project, click on File → Import
Go to General → File System and click Next.
Browse for the library folder previously downloaded and make sure to select all the files inside, which are mandatory for the library to be properly used. Select the current project folder. Under the "Advanced" section, check the items accordingly.
In the example project, click on File → Properties
Go to C/C++ Build → Settings → MCU GCC Compiler → Includes. Under the Include paths, click on the first icon on the left
Insert the library folder location, based on the workspace location (in the example, the library folder was copied inside the project location)
Go to C/C++ General → Paths and Symbols. Under the Source Location, click on the Add Folder button
Add the library folder
Open the main.c file and include the following line in the Include Section
/* USER CODE BEGIN Includes */
#include "RTC_DigitalClock.h"
/* USER CODE END Includes */Then, the library is ready for use.