I’m attempting to set up a simple project where I include the STM HAL within mbed to allow granular control of an ADC (ADC1) within an STM32 chip, while leaving everything else in the OS alone. I am trying to be minimally invasive on the Mbed OS while still getting the control of the ADC I need.
I have found a post from some time ago explaining some steps to take in order to do this. Using STM32 HAL with mbedOS | Mbed
I’ve done the following:
- Create a cubemx project (very simple, basically 1 adc channel and a uart)
- Auto generate the code
- Verify it compiles in CubeIDE, flashes to board, and am able to debug all the way the main()
- Take the clock configs into my Mbed project from the CubeIDE project
- Take the MX_ADC1_Init() function from the CubeIDE into MBed
My issue is that the MX_ADC1_Init() function fails in Mbed (can’t complete), but runs fine in the bare metal when run from cubeIDE. I’m not really sure why. When I debug and step through the Init() function, I see something about an internal regulator being off, causing an error. I can only assume that Mbed is doing some device configuration behind the scenes that is making this Init() routine fail.
Does anyone have any experience in bringing low-level adc control into Mbed OS by using the STM HAL? Maybe there is something else I have to do to get this to work?