Skip to main content
ahmetgunduz
Associate III
September 27, 2019
Solved

I'm trying to blink one led but two led blinks

  • September 27, 2019
  • 1 reply
  • 1134 views

Hi,

i'm trying to blink only one led. I have a problem with one of four leds. Because as you in my code, i'm trying to blink only 'green led'. But 'blue led' blinks also.

#include "stm32f4xx.h" // Device header
#include "stm32f4xx_hal_gpio.h"
 
int main ()
{
	RCC->AHB1ENR |= (4<<1); //initiliazing clock
	GPIO_InitTypeDef GPIO_InitStructure;	
	GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; //push-pull 
 GPIO_InitStructure.Pin = GPIO_PIN_12; //green led
	HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
	HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12); //blue led blinks also!
	return 0;
}

This topic has been closed for replies.
Best answer by Tesla DeLorean

GPIO_InitTypeDef GPIO_InitStructure = {0};

1 reply

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
September 27, 2019

GPIO_InitTypeDef GPIO_InitStructure = {0};

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
ahmetgunduz
Associate III
September 28, 2019

it's working now. Thanks. But I didn't understand how it is works?

Piranha
Principal III
September 28, 2019

Maybe actually learn C language? Read this and you will understand:

https://www.tutorialspoint.com/cprogramming/c_variables.htm