cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with LL_USART_Setbaudrate and ATOMIC access

JamesHolland
Associate II

I'm porting some code over from an STM32F407 processor to an STM32F072 processor. The code uses the low-level driver to change the baudrate. It all works on the 407 but with the 072 I get the following error:

In file included from ../Core/Src/main.c:24:

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_usart.h: In function 'LL_USART_EnableInStopMode':

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_usart.h:619:3: warning: implicit declaration of function 'ATOMIC_SET_BIT' [-Wimplicit-function-declaration]

619 | ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_UESM);

There are several similar errors, the compiler does not seem to be able find the header for the ATOMIC macros. How do I include those without changing any of the files in the HAL? The HAL version that I have is STM32Cube_FW_F0_V1.11.5.

 

 

 

6 REPLIES 6
Souhaib MAZHOUD
ST Employee

Hello @JamesHolland 

Could you please attach your IOC in order to investigate the issue?

KR, Souhaib

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

ile attached, thank you.

I've compared the F4 project with the F0 project:

             In the F4 project the ATOMIC macros are included in stm32f4xx.h

            In the F0 project the ATOMIC macros do not exist in stm32f0xx.h

 

It seems that the HAL code for the UART is calling macros that don't exist.

TDK
Super User

> In the F0 project the ATOMIC macros do not exist in stm32f0xx.h

They exist right here and have for 4 years.

TDK_0-1761314483063.png

 

Maybe you're using an outdated version. Super old project?

 

It's imperative that HAL/CMSIS/include files stay in sync.

 

If you feel a post has answered your question, please click "Accept as Solution".
Sumit_Kumar
ST Employee

Hi @JamesHolland ,

The ATOMIC macros are defined in the stm32f0xx.h file. This file is automatically included if you are using the HAL drivers (with the stm32f0xx_hal_def.h file). However, if you are using LL drivers, this might not be the case. Some LL drivers, such as stm32f0xx_ll_pwr.h and stm32f0xx_ll_rcc.h, do include this file already. To resolve this issue, include the stm32f0xx.h file in your main header file.

 

In main.h:

#include "stm32f0xx.h"

 

--------------------------------------------------------------------------------------------------------------------------------------------------------

If you feel a post has answered your question, please click "Accept as Solution".

JamesHolland
Associate II

The issue that I had was that I had v1.11.0 installed, this is still on the ST download page, but this version does not have the macros. You need to have the patch (1.11.5) installed, its not obvious if that patch is missing because it gets installed in the v1.11.0 folder so you do need to check the release notes.

The previous answer was enough to point me in the right direction.