Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 9 months ago.
Using PA2/PA3 on STM32F072
I'm trying to run mbed on a custom designed PCB that uses the same STM32F072 micro-controller found on the Nucleo board. On the Nucleo board, PA2/PA3 are used for UART and can be configured to be used as normal GPIOs with the solder bridges, but when I try and assign them to an AnalogIn, the code seems to hang at the assignment. I've tried the code without assigning PA2 or PA3 and it works fine, but whenever I assign either of them it'll not run past that line.
Is there a way to get around this and use PA2/PA3 as normal AnalogIns, ideally using the online IDE?
1 Answer
5 years, 9 months ago.
You should be able to use PA2 and PA3 for ADC_IN2 and ADC_IN3, but you will have to import the mbed source code into your project and edit a couple of the Nucleo-F072RB target files. Links to these files for mbed-os and mbed-dev can be found on the hardware page for this board.
The mbed source code assumes that PA2 and PA3 will be used for the SDIO UART for this target. Other peripheral functions for these pins are commented out in the PeripheralPins.c file. This is a possible source of your problem. Remove the comments for ADC_1 in that file and the online compiler should correctly configure those pins as analog inputs. You may need to edit the SDIO UART definitions in the PinNames.h file (eg. to UART_4) to avoid problems if your code tries to use SDIO calls.
You should probably check all of the commented lines in PeripheralPins.c file for other peripheral conflicts (eg. TIM_2, which is used for the us_ticker), since you are not using the Nucleo target for which the online complier was configured.
JR