Questions tagged [hal-library]

The HAL drivers include a complete set of ready-to-use APIs which simplify the user application implementation. It was developed by STMicroelectronics for STM32 microcontrollers.

STM32Cube is an STMicroelectronics original initiative to ease developers life by reducing development efforts, time and cost.

  • The STM32CubeMX, a graphical software configuration tool that allows generating C initialization code using graphical wizards.

  • A comprehensive embedded software platform, delivered per series (such as STM32CubeF4 for STM32F4 series)

    • The STM32Cube HAL, an STM32 abstraction layer embedded software, ensuring maximized portability across STM32 portfolio
    • A consistent set of middleware components such as RTOS, USB, TCP/IP, Graphics
    • All embedded software utilities coming with a full set of examples.

The HAL drivers layer provides a generic multi instance simple set of APIs (application programming interfaces) to interact with the upper layer (application, libraries and stacks). It is composed of generic and extension APIs. It is directly built around a generic architecture and allows the built-upon layers, such as the middleware layer, to implement their functions without knowing in-depth how to use the MCU. This structure improves the library code reusability and guarantees an easy portability on other devices.

The HAL drivers include a complete set of ready-to-use APIs which simplify the user application implementation. As an example, the communication peripherals contain APIs to initialize and configure the peripheral, to manage data transfers based on polling, to handle interrupts or DMA, and to manage communication errors.

The HAL drivers APIs are split into two categories: generic APIs which provide common and generic functions for all the STM32 series and extension APIs which include specific and customized functions for a given family or part number.

The HAL drivers are feature-oriented instead of IP-oriented. As an example, the timer APIs are split into several categories following the functions offered by the IP: basic timer, capture, pulse width modulation (PWM), etc..

The drivers source code is developed in Strict ANSI-C which makes it independent from the development tools. It is checked with CodeSonar static analysis tool. It is fully documented and is MISRA-C 2004 compliant.

The HAL drivers layer implements run-time failure detection by checking the input values of all functions. Such dynamic checking contributes to enhance the firmware robustness. Run-time detection is also suitable for user application development and debugging.

Source document: HAL driver User Manual

131 questions
15
votes
1 answer

Addressing registers with I2C STM32F0 HAL libraries

I'm very new to using STM's CUBE and HAL_libraries. I'm using an STM32F0 microcontroller with 32 pins. The schematic for I2C is correct. So I need a little help here. I have a capacitive sensor (FDC1004) that uses I2C communication. I have to…
yest111
  • 153
  • 1
  • 1
  • 6
14
votes
4 answers

STM32 ADC conversion using HAL

I am trying to learn how to use "new" HAL library from stm32. When I try to do simple ADC conversion it works just one time, but then it stops converting. I suppose End of conversion flag does not get set. I am using STM32f429I Discovery board,…
ScienceSamovar
  • 1,206
  • 3
  • 20
  • 39
10
votes
3 answers

Eclipse + GNU ARM + STM32 - HAL or SPL

I am going to start with ARM development (after 2 years of AVRs) and have picked up the STM DISCOVERY board with the stm32f4 microprocessor on it. I have decided to go with eclipse + ARM gcc since I don't like the code limit on Keil and I don't have…
Ankit
  • 1,751
  • 1
  • 27
  • 48
8
votes
7 answers

Getting PWM to work on STM32F4 using ST's HAL libraries

I'm trying to switch to the ST HAL libraries and can't seem to get the PWM to work. Compiles fine, just doesn't start. In my main() I call the Timer initialization function: /* TIM3 init function */ void MX_TIM3_Init(void) { …
oboist B
  • 83
  • 1
  • 1
  • 7
6
votes
4 answers

I want to learn a real microcontroller with STM32F4. Which library should I use (HAL, SPL, or CMSIS)?

From what I know, ST will stop to develop Standard Peripheral Libraries (SPL) for the next generations of STM32. And HAL is not ideal for people who want to understand well about STM32 and microcontrollers. Can you suggest me which one is the best…
5
votes
1 answer

Large delay between I2C messages on STM32F303 - trying to read as fast as possible

I've got a sensor that I'm reading via I2C. My end goal is to be able to maximize the rate at which I can take these readings. In order to read, I have to write an zero-byte I2C message to the slave to 'wake it', after which I can send a read and…
5
votes
1 answer

STM32 HAL UART Transmit DMA problem

After setting up my project for a custom STM32F7 board which includes a FT2232H UART<->USB converter I got multiple problems when sending (and receiving data). The code I use is mostly generated by CubeMX and is at the end of the post. First of all…
JaneDoe
  • 53
  • 1
  • 5
5
votes
5 answers

I2C busy flag strange behaviour

I've been using STMCUBE combined with Keil for some time now. For most part I like the HAL library and the documentation for STM32f1xx drivers is quite good. I'm doing a project where I am using STM32f103rb Nucleo card combined with an MPU6050…
Nelle
  • 51
  • 1
  • 1
  • 3
4
votes
1 answer

Difference between I2C STM32 HAL functions

I'm using I2C in a project on STM32, and i was wondering what's the difference between HAL_I2C_Master_Transmit and HAL_I2C_mem_write, and the difference between HAL_I2C_Master_Receive and HAL_I2C_mem_read.
DTl
  • 77
  • 1
  • 2
  • 9
4
votes
4 answers

CAN communication not working

I made the following circuit. STM32's are STM32F103C8T6 (Blue Pills). I left out the obvious wires: All four components grounded together Supplied 5V to RX TJA 1050 from RX STM32 Supplied 5V to TX TJA 1050 from TX STM32 simulate this circuit –…
Michel Keijzers
  • 13,867
  • 18
  • 69
  • 139
4
votes
3 answers

How to read from multiple channels of the ADC on an STM32F407?

I am working on a project wherein, I need to read the Analog outputs from 4 sources and convert them to a digital value using a single ADC module on the STM32F407 microcontroller. I want to sample the ADC values every 50ms and therefore have decided…
Shubham Rastogi
  • 41
  • 1
  • 1
  • 2
4
votes
2 answers

Use STM32 interrupt with FreeRTOS

I'm confused in using HAL-defined interrupts with FreeRTOS. I'm trying to implement "6.3 Deferred Interrupt Processing" in the guide of FreeRTOS, but I don't know how to do it. The problem is how to use the peripherals of the STM32 with FreeRTOS.…
Ramo
  • 93
  • 2
  • 2
  • 8
4
votes
2 answers

STM32 HAL drivers

I've been using STM32 ARM microcontrollers for more than two years, the best way of coding that I've found is using the CMSIS and ST std peripheral libraries, and I think it has no restrictions or any main disadvantages. But now I want to try HAL…
electro
  • 375
  • 1
  • 3
  • 13
4
votes
0 answers

UART reception problem when SysTick Interrupt is enabled

I'm using a STM32F411RE-Nucleo board and generating a project with Cube MX for System Workbench. The problem is that HAL_UART_Receive function doesn't receive input from the user, even though I don't change any UART, GPIO, RCC or NVIC…
baqx0r
  • 311
  • 1
  • 4
  • 13
3
votes
0 answers

Migrating from STM32

Our company spent couple years streamlining development and porting everything from a mess of different platforms to one unified STM32-based architecture. And now with global chip shortage it came back to haunt us. A search for devices with similar…
Maple
  • 11,755
  • 2
  • 20
  • 56
1
2 3
8 9