#include "stm32f10x.h" void delay(uint32_t time) { time=time*2318; while(time) time--; } int main() { RCC->APB2ENR |= 1<<4; GPIOC->CRH |=0x00000002; while(1) { GPIOC->BSRR= 1<<8; delay(1000); GPIOC->BRR = 1<<8; } }
Buton kullanma kodlar ve videosu
#include "stm32f10x.h" // Device header _Bool x=0; int main() { RCC->APB2ENR |= (1 << 2); /* Enable GPIOA clock */ RCC->APB2ENR |= (1 << 4); /* Enable GPIOC clock */ GPIOA->CRL &= 0x00000000; // Set to Zero Port A GPIOA->CRL |= 0x00000008; // Set as a input PA0 GPIOC->CRH = 0x00000022; // Set as a output PC8 & PC9 while (1) { x=(GPIOA->IDR & 0x0000001); if(x) // PA0 ON (Led4) // { GPIOC->BSRR = 1<<8; // LED ON PC8 } else { GPIOC->BRR = 1<<8; // LED OFF PC8 } } }
Hiç yorum yok:
Yorum Gönder