LED blink in STM32F4XX using embedded C.

#include "stm32f4xx.h"
void myDelay(int value)
{
	volatile int i,j;

	for(i =0;i< value;i++){ 
		j++; 	
        } 
} 
int main(void) 
{
 	//Enable the GPIO clock for PORT C using AHB and RCC
 	RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;

	//Set mode register
	GPIOA->MODER |= GPIO_MODER_MODE6_0;

	//SET OTYPER TO PUSH-PULL
	GPIOA->OTYPER &= ~(GPIO_OTYPER_OT_6);

	//SET OSPEEDR
	GPIOA->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR6;

	//PUPDR
	GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR6); //~(11) = NO pullup/pulldown

	while(1)
	{
		//turn on led
		GPIOA->ODR |= GPIO_ODR_OD6;

		//WAIT
		myDelay(50000);

		GPIOA->ODR &= ~GPIO_ODR_OD6;

		myDelay(50000);

	}
}

About PraveenMax
My Interests: ------------------ Programming , Drawing & Music

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: