cancel
Showing results for 
Search instead for 
Did you mean: 

HAL De-Init Pin for use with another peripheral

abotha
Associate III
Posted on March 09, 2017 at 08:11

Good Day

I am using the built-in comparator on a STM32F072RB. The comparator works fine, but now I want to be able to measure the amplitude of the sine-wave (already withing 0-3.3V limits) by 'removing' the pin from the comparator and 'giving' it to the ADC Channel 1 that it also able to operate from that same pin. 

How do I De-Initialize the pin from the comparator (COMP1_INP) and allocate it to the ADC_IN1? My sine-wave is on pin PA1. 

I have checked the MXCube examples for the STM32F0xx family but couldn't find an appropriate example.

Kind Regards

AJ

#hal #adc #hal_gpio_deinit #stm32-f0
1 REPLY 1
S.Ma
Principal
Posted on March 09, 2017 at 08:48

I guess the best way to know is to try it out, to get a quick answer, using a debugger.

Not used comparator so far... In the Ref Man:

0690X00000606WRQAY.png

So the pin is in analog mode with an analog mux depending on the chosen alternate function.

ADC, as long as the pin is in analog input, the ADC is already connected to the same signal.

It seems you should be able to use ADC without de-init the COMP. Just remember that an ADC conversion might make a ripple on the line which should be ignored by the comparator (application dependent).