Lab 3

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

/*#include "stm32f4xx.

h"

int b;

void main ()

RCC->AHB1ENR |=0X09;

GPIOD->MODER|=1<<2*15;

GPIOD->OSPEEDR=(unsigned) (2<<2*15);

GPIOD->OTYPER=0<<2*15;

GPIOD->PUPDR=1<<2*15;

while(1)

b=0x01&GPIOA->IDR;

if (b==1)

GPIOD->ODR|=(1<<15);

else GPIOD->ODR&=(0<<15);

*/

/*#include "stm32f4xx.h"

int b;

void main()

RCC->AHB1END |=0X09;

GPIOD->MODER|=1<<2*15;
GPIOD->OSPEEDR=(unsigned) (2<<2*15);

GPIOD->OTYPER=0<<2*15;

white(1

b=0x01&GPIO->IDR;

if (b==1)

GPIOD->ODR|=(1<<15);

else GPIOD->ODR&=(0<<15);

}*/

#include "stm32f4xx.h"

int dt=1500000;

int b;

void wait(uint32_t nr)

uint32_t index=0;

while(index++<nr);

int main()

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOA, ENABLE);

GPIO_InitTypeDef GPIO_InitStruct;

GPIO_InitStruct.GPIO_Pin=(GPIO_Pin_15);

GPIO_InitStruct.GPIO_Mode=GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_2MHz;

GPIO_InitStruct.GPIO_OType=GPIO_OType_PP;

GPIO_InitStruct.GPIO_PuPd=GPIO_PuPd_UP;

GPIO_Init(GPIOD, &GPIO_InitStruct);

GPIO_InitStruct.GPIO_Pin=(GPIO_Pin_0);

GPIO_InitStruct.GPIO_Mode=GPIO_Mode_IN;

GPIO_InitStruct.GPIO_PuPd=GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStruct);

while(1)

b=0x01&GPIOA->IDR;

GPIOD->ODR|=(b<<15);

GPIOD->ODR&=(b<<15);

You might also like