2019-08-06 08:06 AM
Hello everyone,
I'm working on a project using an stm32f030rc. I need to use PC15 as a GPIO input but it appears I'm unable to.
I understand the couple PC14/PC15 is shared with the LFE oscillator, but of course I'm not using that function. Moreover, I am able to read the correct pin level on the PC14 GPIO. In the datasheed regarding my model the PC15 pin is marked as a I/O with OSC32_OUT as additional function: can it be used as input at all?
For reference, this is the C code I'm using to test the functionality; I'm using libopencm3 for initialization.
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
static void clock_setup(void)
{
rcc_clock_setup_in_hsi_out_48mhz();
/* Enable GPIOA, GPIOB, GPIOC clock. */
rcc_periph_clock_enable(RCC_GPIOA);
rcc_periph_clock_enable(RCC_GPIOB);
rcc_periph_clock_enable(RCC_GPIOC);
rcc_periph_clock_enable(RCC_DBGMCU);
/* Enable clocks for GPIO port B and C*/
gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO5);
gpio_mode_setup(GPIOC, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO15);
gpio_mode_setup(GPIOC, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO14);
}
int main(void)
{
unsigned long long i = 0;
clock_setup();
/* Blink the LED (PA8) on the board with every transmitted byte. */
while (1)
{
gpio_toggle(GPIOA, GPIO5); /* LED on/off */
for (i = 0; i < 400000; i++) /* Wait a bit. */
__asm__("nop");
// This conditional is never entered
if (gpio_get(GPIOC, GPIO15) == 0) {
__asm__("nop");
__asm__("nop");
__asm__("nop");
}
// This one works
if (gpio_get(GPIOC, GPIO14) == 0) {
__asm__("nop");
__asm__("nop");
__asm__("nop");
}
}
return 0;
}
Solved! Go to Solution.
2019-08-06 08:11 AM
I believe it should be, is it connected to other things in your design?
Check Data Sheet and Errata for potential concerns. Should be in backup power domain, but should work as input is LSE/BYPASS etc are disabled in RCC.
2019-08-06 08:11 AM
I believe it should be, is it connected to other things in your design?
Check Data Sheet and Errata for potential concerns. Should be in backup power domain, but should work as input is LSE/BYPASS etc are disabled in RCC.
2019-08-06 08:56 AM
Hardware problem, e.g. bad solder joint?
JW
2019-08-06 10:00 AM
It is supposed to be a button, so only a capacitor and a pull up resistor is connected to the pin. I checked with the oscilloscope and the signal seems to arrive cleanly to the MCU. Tomorrow I'll double check for safety.
2019-08-06 11:47 PM
After thoroughly checking the board I can confirm that a bad soldering was the cause. The fact that PC15 has additional functions had me looking in the wrong direction for a while, thank you for confirming it had nothing to do with software configuration.