0% found this document useful (0 votes)
3 views5 pages

Interface Programs

The document outlines three experiments using the STM32F100RB Discovery Kit. Experiment 1 interfaces a switch to control a relay, buzzer, and LED; Experiment 2 displays hexadecimal digits on a 7-segment LED; and Experiment 3 controls a stepper motor to rotate in both clockwise and anti-clockwise directions. Each experiment includes a list of components used, configured ports, and corresponding programs in C.

Uploaded by

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

Interface Programs

The document outlines three experiments using the STM32F100RB Discovery Kit. Experiment 1 interfaces a switch to control a relay, buzzer, and LED; Experiment 2 displays hexadecimal digits on a 7-segment LED; and Experiment 3 controls a stepper motor to rotate in both clockwise and anti-clockwise directions. Each experiment includes a list of components used, configured ports, and corresponding programs in C.

Uploaded by

rajitha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Experiment 1:

Interface Switch/ Relay/ Buzzer/ LED

Aim: Interface a simple Switch and display its status through Relay, Buzzer and LED.

Components Used:

STM32F100RB Discovery Kit

USB to mini cable

GPIO card

Ports configured:

PA0 – On board push button (internal)

PC0 – LED

PC1 – Buzzer

PC2 – Relay

Program:

#include "stm32f10x.h"

int main(void)

RCC->APB2ENR |= 0x10 | 0x04;

GPIOA->CRL = 0x08;

GPIOC->CRL = 0x0111;

while (1)

if((GPIOA->IDR & 0x1) == 1)

GPIOC ->BSRR = Ox07;;

else

GPIOC ->BRR = 0x07;

}
Experiment 2:

Seven Segment LED Display

Aim: Display the Hex digits 0 to F on a 7-segment LED interface

Components Used:

STM32F100RB Discovery Kit

USB to mini cable

Power adapter

Seven Segment LED card

Ports configured:

PC0 – A PC4 – E

PC1 – B PC5 – F

PC2 – C PC6 – G

PC3 – D PC7 – Dp

Program:

#include "stm32f10x.h"

void delay(int n);

int main(void)

unsigned char Pattern[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,

0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};

int i;

RCC ->APB2ENR |= 0x10;


GPIOC ->CRL = 0x11111111;

while (1)

for(i = 0 ; i <= 15; i++)

GPIOC ->ODR = Pattern[i];

delay(10);

void delay(unsigned int time)

int i,j;

for(i=0;i<=time;i++)

for(j=0;j<=65000;j++);

for(j=0;j<=65000;j++);

for(j=0;j<=65000;j++);

for(j=0;j<=65000;j++);

Experiment 3:

Stepper Motor

Aim: To interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.

Components Used:

STM32F100RB Discovery Kit

USB to mini cable

Power adapter

Stepper Motor Interface card

Stepper Motor
Ports configured:

PC0 – IN1

PC1 – IN2

PC2 – IN3

PC3 – IN4

PA0 – On board Push Button(internal)

Program:

#include "stm32f10x.h"

void delay(int n);

int main(void)

int i;

RCC ->APB2ENR |= 0x10 | 0x04;

GPIOC->CRL = 0x1111;

GPIOA->CRL = 0x04;

while (1)

{
// clockwise

GPIOC->ODR = 0x0001;

delay(5);

GPIOC->ODR = 0x0002;

delay(5);

GPIOC->ODR = 0x0004;

delay(5);

GPIOC->ODR = 0x0008;

delay(5);

// Anticlockwise

GPIOC->ODR = 0x0008;

delay(5);

GPIOC->ODR = 0x0004;

delay(5);

GPIOC->ODR = 0x0002;

delay(5);

GPIOC->ODR = 0x0001;

delay(5);

void delay(unsigned int time)

int i,j;

for(i=0;i<=time;i++)

for(j=0;j<=1500;j++);

for(j=0;j<=1000;j++);

You might also like