Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
21 views2 pages

Flashing of LEDs

Uploaded by

Avinash cliffe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Flashing of LEDs

Uploaded by

Avinash cliffe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Ex.

No:
DATE : Flashing of LEDs

AIM

To develop a ‘C’ program to make the LED blink (including delay routine).

APPARATUS & SOFTWARE REQUIRED

1. VSK-SCM4 Development board.


2. IAR IDE software.
3. Flash Loader Demonstrator.

THEORY
LEDs are based on the semiconductor diode. When the diode is forward biased (switched on),
electrons are able to recombine with holes and energy is released in the form of light. This effect is called
electroluminescence and the color of the light is determined by the energy gap of the semiconductor.

PROCEDURE

1. Double click IAR Embedded Workbench in the Desktop.


2. To create a new project, choose Project>Create New Project. In the Dialog box, set the tool chain to
ARM and select the project template as empty project.
3. To type the program, select new from file menu and save it with the name ( anyname.c)
4. Add the necessary library files to the project.
5. Build the program. Hex file will be generated if the program has no errors.
6. Change the mode of the program into downloading mode by using Flash loader software.
7. To view the output, after downloading your program change the board to execution mode in cortex
M4 development board and reset it.
8. The four LEDs on the board will toggle with a delay.
PROGRAM

/*Header Files*/
#include"stm32f4xx.h"

/*Delay Function*/
void delay()
{
long int i;
for(i=0;i<9000000;i++);
}

/*Function to Initialize LED*/


void led_init()
{
RCC->AHB1ENR = 1<<3; //enable clock for port D
GPIOD->MODER = 0X00550000; //enable pD8,pD9,pD10,pD11 as output mode
}

/*Main Routine*/
void main()
{
led_init();
while(1)
{
GPIOD->ODR = 0X0F00;
delay();
GPIOD->ODR = 0X0000;
delay();
}
}

RESULT
Thus the C-Language program to make the LED blink was developed and output was verified. The
speed variation was verified by changing the delay function.

S.No Mark Allocation Max. Marks


Marks Awarded
1 Preparation 2
2 Interest and
2
Involvement
3 Skill in completing the
4
experiments & results
4 Viva-Voce 2
Total 10
Date Sign

You might also like