11
votes
I want to learn a real microcontroller with STM32F4. Which library should I use (HAL, SPL, or CMSIS)?
If you really want to learn a specific microcontroller, ditch the vendor provided libraries (which are often bug ridden anyway), and work from the datasheet to set registers up yourself.
You're best ...
9
votes
Accepted
STM32 HAL_DELAY hangs with HAL_GetTick=0
As an advanced STM32 user I can say that you did not handle the SysTick interrupt.
The HAL library enables the SysTick timer and interrupts for it.
In stm32f4xx_it.c file add this function call:
<...
9
votes
I want to learn a real microcontroller with STM32F4. Which library should I use (HAL, SPL, or CMSIS)?
If your goal is to understand in detail how the microcontroller works, then just use the register declaration file (stm32fxxx.h) and work directly with the hardware. It is not that difficult, and for ...
9
votes
Accepted
Difference between I2C STM32 HAL functions
The MEM functios can directly read and write devices that have register address based access. They write the register addresss before reading or writing the register data. Most chips are like this. ...
8
votes
How to use libraries with delays inside within a time critical STM32 HAL application?
You can implement an RTOS and replace the HAL_Delay for the equivalent Thread_Sleep function available.
But the library doesn't look very complicated, you can probably pick any of the options and do ...
7
votes
I2C busy flag strange behaviour
ST has released an errata sheet called:
STM32F100xC, STM32F10 0xD and STM32F100xE high-density value line device limitations.
The interesting point here is:
2.9.7 I2C analog filter may provide ...
7
votes
Accepted
STM32F072 - Working with HAL and FatFS
I've finally manage to implement low-level drivers and they seem to work nicely.
I'm sharing source code of my implementation in case somebody else gets stuck at the same part that I was.
7
votes
Getting PWM to work on STM32F4 using ST's HAL libraries
I'm using STCubeMX and the generated HAL initialization files. Process verified on my F302 Nucleo Board. I set up advanced Timer 1 (TIM1) with a normal and complementary output, no dead time.
Here's ...
7
votes
Multiple(five) alarm time setting in stm32f0 mcu
Check AN3371 at the official website of ST.
However, according to paragraph 2 there are only 2 alarms (A and B).
Alternatives:
Keep 5 alarms in your own code, set the first alarm (A) as alarm 1. ...
7
votes
Accepted
STM32 RTC with HAL libraries
The solution is to call both GetTime and GetDate at the same time, If you call only GetTime it does not update correctly:
...
6
votes
Accepted
STM32 HAL drivers
If you do not want to use the STM32CubeMX code generator tool but still need simple example projects then you should use the STM32Cubexx firmware examples that are available for all STM32 series.
...
6
votes
I2C busy flag strange behaviour
This is less an answer and more a warning...
I got stuck with the same problem and the code above helped (along with stretching the I2C reset and initialising the clock before the GPIO - see linked ...
6
votes
Accepted
STM32 HAL UART Transmit DMA problem
First of all I can't get the stm to transmit at baud rates higher then the standard 115200, according to the datasheets both the FT2232H and the STM32F7 should be capable of at least 12M baud.
The ...
6
votes
Accepted
Coding style in STM32 HAL code
A do { something; } while (0) is a typical pattern in macros, where you want to make sure that all instructions get executed.
Example why this is important:
...
5
votes
How to read from multiple channels of the ADC on an STM32F407?
hadc1.Init.ScanConvMode = DISABLE;
the sequencer is disabled so you cant read or even convert data coming from the other channel.
Also you have to define the rank ...
5
votes
STM32 ADC conversion using HAL
I would like to add that for my setup (nucleo-h743) it was not enough to set:
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
I also had to enable the overrun ...
5
votes
Accepted
LTC4015 variable I2C speed operation
Your snip of the datasheet is missing a very important part - the heading.
If you look up from the 400kHz you can see it's in the MAX column.
So the speed specified is simply the maximum clock rate. ...
5
votes
STM32: Difference between HAL_xxx_Init() and HAL_xxx_MspInit()
The ST User Manual UM1725 - Description of STM32F4 HAL and LL drivers, see pages 61 - 63, gives an explanation:
The peripheral initialization is done through HAL_PPP_Init() while
the hardware ...
5
votes
Large delay between I2C messages on STM32F303 - trying to read as fast as possible
These Callback functions are called from the I2C interrupt handler. You shouldn't make other API calls from them. HAL_I2C_Master_Transmit_IT() check timeouts etc which might not work from an interrupt ...
4
votes
Accepted
How to know UART DMA TX is finished for RS485 enable process in STM32F4 CubeMX
You should use the following function:
HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
and make sure that the ...
4
votes
Misunderstanding of hal_spi Communication Functions
SPI is a very simple interface, which essentially amounts to connecting shift registers between two chips. There is no handshaking of any sort that occurs. If nothing is connected to the SPI of the ...
4
votes
Use STM32 interrupt with FreeRTOS
I am aware this is an old question, but I had issues with that as well. The new FreeRTOS for STM32 recommend to use signals as faster and simpler alternative to Semaphores, especially for the ...
4
votes
STM32 PWM output frequency is off
You cannot produce 12.288 MHz by integer division of a 180 MHz source.
The closest you would come would be dividing by 14, which would yield the 12.857 and some following decimals, which is likely ...
4
votes
Accepted
How to use timers in STM32 board and HAL library in order to measure speed of motor?
Best way is to set up a timer in encoder mode to count the pulses of your sensor. If you have both A and B pulses then choose encoder mode TIM_ENCODERMODE_TI12 if ...
4
votes
STM32 SPI SCLK stops ticking
I think you misunderstood the functionality of HAL_SPI_TransmitReceive function. It doesn't first transmit tx buffer then receive to rx buffer. It does both at the ...
4
votes
CAN communication not working
CANH (Channel 2) and CANL (Channel 0) receive info
If channel 2 is truly CANH, with the same time base as CANL on channel 0, then that's obviously your problem. It doesn't look healthy at all, it ...
4
votes
Timer1 on stm32f4
I don't really like the HAL, so here is how to do what you want by just accessing the timer peripheral directly:
...
4
votes
Timer1 on stm32f4
My solution would be almost identical to @Jon's, but I'd start the timer in one-shot mode, to avoid getting a second interrupt when processing the first takes too long. This way, no timer stop ...
4
votes
Accepted
STM32F4 struct unnamed has no field brr
BRR Register isn't defined for the GPIOs in the STM32F4 MCUs .You can use BSRR regster instead. for more information see the STM32F4-Reference manual page 286 and also STM32f4xx.h file for the ...
4
votes
STM32 HAL driver for register value update
While it would be tempting to think that if you are going to use the HAL libraries, you should maintain that abstraction and not pierce it, in fact it is often necessary to bypass them.
If you look ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
stm32 × 153hal-library × 134
microcontroller × 27
stm32cubemx × 25
i2c × 22
uart × 13
c × 11
spi × 11
timer × 10
adc × 7
pwm × 7
dma × 6
embedded × 4
arm × 4
interrupts × 4
gpio × 4
can × 4
nucleo × 4
dac × 3
usb-device × 3
rtc × 3
keil × 3
cmsis × 3
hal × 3
usb × 2