cancel
Showing results for 
Search instead for 
Did you mean: 

How to Include HAL Libraries into Already Existing Project

GSkoumal
Associate II

Hello,

I am using an STM32F407G-DISC1 to run an open source program called Picovoice. More specifically their project at the following link (https://github.com/Picovoice/picovoice/tree/master/demo/mcu/stm32f407/stm32f407g-disc1). Unfortunately they do not have an .ioc file in the project for me to enable and generate code for the UART HAL libraries. Does anyone know how I could potentially add those libraries to the already existing project?

 

I am planning to use UART4 on pins PA0 and PA1 if that helps at all. Any info would be appreciated.

Thanks!

8 REPLIES 8
STTwo-32
ST Employee

Hello @GSkoumal and welcome to the ST Community :smiling_face_with_smiling_eyes:.

What i suggest you is to create a new project wher you configure the USART interface that you are going to use starting from CubeMX. Then generate your project. Take the same includs and generated codes and add them to the first projects (don't forget to add the files included on the USART project and that are not existing on the original one. Also, make sure about check that you are using the correct paths on your configurations).

Best Regards.

STTwo-32 

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.

Thanks for getting back so quick. I've done what you recommended and am close but am running into another road block. Now whenever I build the function HAL_UART_Init() is being flagged as undefined. I realized that for some reason the file "stm32f4xx_hal_uart.c" was not properly being included. Looking in the driver folder the file is present, but greyed out. I placed "#define HAL_UART_MODULE_ENABLED" in the 'stm32f4xx_hal_conf.h' file in the Inc folder. This should include the UART .h file, and in turn, the .c file but it doesn't appear to. Additionally if I attempt to simply place #include "stm32f4xx_hal_uart.c" at the top of main the build claims so such file exists. Any idea why this might be? 

I've attached an image of how the HAL driver folder appears in my project manager.

Thanks again!

 

Pavel A.
Evangelist III

 #include "stm32f4xx_hal_uart.c" at the top of main

 #include "../Src/stm32f4xx_hal_uart.c" at the *bottom* of main.c  ))

 

Huge help that worked! But now the stm32f4xx_hal_uart.c file has an error where it says the ATOMIC_CLEAR_BIT and ATMOIC_SET_BIT functions are undefined. Sorry this is a confusing one for me!

Was able to compile the code after switching all ATOMIC functions to just SET_BIT and CLEAR_BIT. Code runs but the data now isn't being sent properly, it just gets stuck in UART_WaitOnFlagUntilTimeout() forever. I tried sending the same frame on the UART when in a different project with an .ioc file and it worked. Something is wrong with how it was carried over.

Pavel A.
Evangelist III

ATOMIC_SET_BIT, ATOMIC_CLEAR_BIT are defined in Drivers/CMSIS/Include/stm32f4xx.h

If this is undefined, you may be using outdated version of CubeF4 package or weird mix of versions => not going to work. Please check that you have at least a certain consistent version of the F4 HAL & CMSIS library.

 

 

How can I check to see what version of those libraries I have? The github project in my first post has the drivers I need to match. Once I know where could I find the outdated versions of the uart library to include? 

Thanks again for all of your help I am at a complete loss with this.

How can I check to see what version of those libraries I have? 

This is a good question, unfortunately hard to do. The library version is in a xml file in the "repository". But by default CubeMX/ide copies the library files into user's project without this file so the version information is lost.