danak6jq / RAK3172

Port of STM32WLxx example for RAK3172
30 stars 11 forks source link

Reading ADC #10

Closed arthurLNF closed 1 year ago

arthurLNF commented 1 year ago

I don't know if this is an issue, but how do you enable ADC readings on RAK3172 by the IOC file?

danak6jq commented 1 year ago

Like any STM32-family part - you use the Cube configurator to select the ADC, enable channels. Because I read the battery voltage, the IOC file is already configured to enable the ADC, so launch Cube and have a look. One twist is that when the MCU goes into STOP mode (which is basically all the time it's not active), the ADC is powered-off and requires re-initialization. See https://github.com/danak6jq/RAK3172/blob/master/Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.c#L247 for an example of how to do that.

arthurLNF commented 1 year ago

The issue is when i enable other channels, like ADC_CHANNEL_3 on PB4, the file adc_if.c is deleted when the code is generated. How can I enable other Channels without breaking the end node skeleton?