0% found this document useful (0 votes)
141 views15 pages

CH3 - STM32 Softwareprogramming

Uploaded by

houda bouzekri
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
0% found this document useful (0 votes)
141 views15 pages

CH3 - STM32 Softwareprogramming

Uploaded by

houda bouzekri
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 15

Hanene Ben Fradj

Master SIIO
Mise à jour : 2022/2023
OUTLINE
The STM32F40x Dicovery card features
STM32 Software Layers :
CMSIS
HAL Library

STM32 Programming STEPS

2
2
La carte
STM32F407VG

3
STM32F4-Discovery Board in zoom (1)

4
STM32F4-Discovery Board (2)

5
Ordering Information Scheme

6
Developement toolchains supported

 IAR EWARM
 CubeIDE
 KEIL MDK-ARM
 GCC-based IDEs including free SW4STM32 from AC6
 ARM mbed Enabled™ online

7
STM32F4xx Value Line necessary docs
 RM0090 (Reference Manual): Peripherals description…

 Datasheet STM32F407xx : Electrical parameters…

 UM1725 : Description of STM32F4 HAL and low-layer drivers

 UM1472 (DISCOERY KIT with STM32F407VG MCU value line Discovery):


STM32 discovery board description, electrical schematics…

All docs are available from www.st.com

8
The CMSIS programming standard
• Definition:
The Cortex-M™ Microcontroller Software Interface Standard (CMSIS) is defined in close
cooperation with various silicon and software vendors and provides a common
approach to interface to peripherals, real-time operating systems and middleware
components. For more details, please refer to www.onarm.com.
• CMSIS layer structure

Hal peripherals Driver

9
HAL overview
HAL inclusion in user application

stm32f4xx_hal_ppp.c et .h n’est pas uniquement utilisé


pour désigner un seul fichier mais elle s’étend à un certain
nombre de fichiers.

Chaque fichier étant relatif à l’un des périphériques du


microcontrôleur (ppp étant remplacée par l’abréviation du
périphérique). 10
HAL overwiew
HAL file components

11
Using HAL Library 12

 the PPP peripheral is initialized and can be enabled by making a call to


PPP_Cmd(..) function: HAL_PPP_Cmd(PPPx, ENABLE);
 Note: This function is used only for communication peripherals like UART,
SPI, …

 To access the functionality of the PPP peripheral, the user can use a set of
dedicated functions. These functions are specific to the peripheral and for
more details refer to STM32F4xx Firmware Library User Manual.

Example of GPIO Functions are defined in


stm32f4xx_hal_gpio.h
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init);
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin);

GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);


void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin);
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
Basic Configuration Steps
In user application main.c #include "stm32f4xx_hal.h"

Enable bus peripheral clock using macros


__HAL_RCC_GPIOA_CLK_ENABLE() In stm32f4xx_hal_rcc.h
__HAL_RCC_GPIOD_CLK_ENABLE(); In stm32f4xx_hal_rcc_ex.h

Pheripheral configuration by data structure declaration


PPPx_InitTypeDef PPP_InitStucture; in stm32f4xx_hal_PPP.h

Pheripheral configuration : Data structure members defined in


stm32f4xx_hal_PPP.h
 PPP_InitStucture.memberX = valX;
 PPP_InitStructure.memberY = valY;
 ………

Use Read or Write functions implemented in stm32f4xx_hal_PPP.c


Example : HAL_PPP_Init(PPPx, &PPP_InitStructure); 13
GPIOC Configuration example
Example : GPIOC port of the STM32 configuration:

AHB2 AHBx = AHB1

Cortex M4 1. GPIO_InitTypeDef GPIO_InitStructure;

2. __HAL_RCC_GPIOC_CLK_ENABLE();// activer l’horloge


AHB1
3. Configurer le périphérique GPIOC
Bridge GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pin =PIO_PIN_3;
APB GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIOA
GPIO_InitStructure.Alternate =
GPIOB GPIO_InitStructure.Speed =
GPIOC ADC
GPIOD UART 4 . Utilisation des pilotes
GPIOF TIM
GPIOE DAC Initialisation : HAL_GPIO_Init (GPIOC, &GPIO_InitStructure);
GPIOH I2C Write : HAL_GPIO_WritePin(GPIOC,GPIO_PIN_3, GPIO_PIN_SET)
Read : GPIO_PinState HAL_GPIO_ReadPin(GPIOC, GPIO_Pin_3);

14
these informations are available in stm32f4xx_hal_gpio.h and stm32f4xx_hal_gpio.c
Keil Project Management

This folder contains the Cortex-M4F CMSIS files:


Core Peripheral Access Layer: contains name definitions,
address definitions and helper functions to access Cortex-
M4F core registers and peripherals…
CMSIS DSP Software Library: features a suite of common
signal processing functions for use on Cortex-M processor
based devices. The library is completely written in C.

This folder contains all the subdirectories and files that make up
the core of the library:
- the Peripheral's Drivers header files
- the Peripheral's Drivers source files.

15

You might also like