I'm a beginner, and I'm using an STM32 Blue Pill board for the first time. I completed a basic tutorial on how to activate the PC13 pin (on-board LED), but now that I'm trying to get an external LED to blink on a breadboard, I'm having issues.
I'm using the STM32CubeIDE, and allowed the IDE to autogenerate the configuration code that I need to use pin PA0 as GPIO output:
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET);
/*Configure GPIO pin : PC13 */
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pin : PA0 */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
Within my loop, I'm simply running
while (1)
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, 1);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, 0);
HAL_Delay(500);
}
Despite this simple code, I can't get the LED to blink. Here's a picture of my circuit:
To summarize, I have the 3.3v and ground pins connected to the breadboard power rails at the bottom (with a red power LED). I have a jumper cable connecting the A0 pin to row 25, and a 330Ω resistor in series with a 5mm LED with a forward voltage of 3.0V and a forward current of 20mA. I then connect the cathode of the LED to the negative power rail on the breadboard (attached to board ground).
I've tried swapping jumper cables, output pins, LEDs, resistance, but nothing has worked. I connected the pin jumper cable to the positive power rail, and the LED lit up (as expected), so I don't think there's something wrong with my circuit. I've also re-programmed the MCU to make sure my program was uploading correctly. Perhaps I'm misunderstanding the relationship between the pin and ground? Any help would be appreciated.