0% found this document useful (0 votes)
5 views

Embedded EXP 1[1]

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Embedded EXP 1[1]

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

23MPE0005

SCHOOL OF ELECTRICAL ENGINEERING

MPED610P - Embedded System Design for Power Electronic Applications Lab

LABORATORY RECORD

Name of the Student SRIYA MAHESWARI

Reg. Number 23MPE0005

Course / Semester. M-Tech / Second Semester

Branch Electrical and Electronic Engineering

Subject Power Electronics and Drives

1
23MPE0005

EXPERIMENT NO : 1

LED INTERFACING

AIM:

Write an embedded C program to interface LED/LEDs with ARM cortex controller using

(i) Nucleo Board

(ii) Discovery Board

And verify the same in hardware.

APPARATUS:

Device used: STM32476RGT6 (Nucleo), STM32F407VGT6 (Discovery) , STM32 Cube IDE.


Programme: Embedded C language.

2
23MPE0005

PROGRAM:
(i) LED INTERFACING USING NUCLEO BOARD

#include "stm32l4xx.h"
void configureLED(void);
volatile unsigned int LED_state;
void msDelay(volatile int msTime);
int main(void)
{
//configure LED
configureLED();
//define delay function
msDelay(1000);
//gpiod->odr = (0x5UL<<12);
while(1)
{
GPIOA->ODR ^= (0x1UL<<5);
LED_state = GPIOA->ODR;
msDelay(200);
}
}
void configureLED(void)
{
RCC->AHB2ENR |=(1UL<<0);
GPIOA->MODER &= ~(0xFFUL<<5*2);
GPIOA->MODER |= (0x01UL<<5*2);
}
void msDelay(int msTime)

3
23MPE0005

{
//Assume for loop take 12 clock cycles
and system clock is 16MHz
int Time=msTime*1333;
for(int i=0;i<Time;i++);
}

OUTPUT

4
23MPE0005

(ii) LED INTERFACING USING DISCOVERY BOARD

#include "stm32f4xx.h"
void configureLED(void);
volatile unsigned int LED_state;
void msDelay(volatile int msTime);
int main(void)
{
//configure LED using discovery board
configureLED();
//define delay function
msDelay(1000);
//gpiod->odr = (0x5UL<<12);
while(1)
{
GPIOD->ODR ^= (0xFUL<<12);
LED_state = GPIOD->ODR;
msDelay(250);
}
}
void configureLED(void)
{
RCC->AHB1ENR |=(1UL<<3);
GPIOD->MODER &= ~(0xFFUL<<12*2);
GPIOD->MODER |= (0x55UL<<12*2);
}

5
23MPE0005

void msDelay(int msTime)


{
//Assume for loop take 12 clock cycles
and system clock is 16MHz
int Time=msTime*1333;
for(int i=0;i<Time;i++);
}

OUTPUT

6
23MPE0005

RESULT

Embedded C program to interface LED/LEDs with ARM cortex controller using Nucleo
Board and Discovery Board was done and verified the same in hardware.

You might also like