0

I am trying to Blink external LED using STM32CubeIDE and Proteus

     while (1)
  {
      HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
      HAL_Delay(100);
  }

STM Configuration [Proteus Blue Pill During Simulation)2

The LED doesn't blink

Clifford
  • 88,407
  • 13
  • 85
  • 165
Sherif Beshr
  • 23
  • 1
  • 8
  • 1
    Did you configure `PA1` as a GPIO output pin (can be done in STM32CubeIDE)? – rel Aug 04 '21 at 14:28
  • @rel yes It's configured as output as shown in first picture – Sherif Beshr Aug 04 '21 at 14:59
  • Try to set breakpoint to see if the app actually reach this code. – GAMELASTER Aug 04 '21 at 16:14
  • There are many things that could be wrong, none of which are in the code fragment you have shown. Have you initialised the GPIO? Have you initialised the core clock? How you do that may vary depending on the framework you are using (if any). If it is a CubeMX project post likely `SystemClock_Config()` and `MX_GPIO_Init()`, like at https://wiki.st.com/stm32mcu/wiki/STM32StepByStep:Step2_Blink_LED#Edit_main-c_to_toggle_the_LED – Clifford Aug 04 '21 at 17:07
  • 2
    OK - the first thing you have to get right is the **orientation of the LED** - Anode to +ve. You have it the wrong way around. Either that or connect the cathode to GND rather then +3v3. – Clifford Aug 04 '21 at 17:18

2 Answers2

1

I am assuming that you have configured the pin to be output correctly with no pull up or pull down resistor. Hence you will need to terminate the LED into the ground instead of 3.3V.

In the event there is no pull up or pull down resistor, the pin is neither high or low, the pin is in a "z-state" hence when you toggle the LED from low to high there is no potential difference between the pin and the LED so no current flows, and when the pin goes from High to low, the diode property (only allows current flow in one direction) of the LED doesn't let current flow into towards the board.

vision.io
  • 19
  • 2
0

The Problem Solved. First the polarity of the LED. Second the library of the blue pill on proteus doesn't support STM32FC103C8 that I selected on STM32CubeIDE. STM32FC103C6 should be selected instead.

Sherif Beshr
  • 23
  • 1
  • 8