stm32f103 led 闪烁的电路图和代码

/* Main.c file generated by New Project wizard
 *
 * Created:   周六 7月 11 2020
 * Processor: STM32F103C4
 * Compiler:  GCC for ARM
 */
// Refer to 教程 https://www.bilibili.com/video/BV1Kb411y7BU?p=9
#include <stm32f1xx.h>
//0x4001 0C00
#define GPIOB_MODER *(unsigned int*)(0x40010C00)
#define GPIOB_ODR *(unsigned int*)(0x40010c0c)
#define CLOCKENABLE  *(unsigned int*)(0x40021018)
extern int add(int ,int );
int main (void)
 { 
   // Write your code here
	CLOCKENABLE |= (1<<3) ;
	GPIOB_MODER |= 1 ; 
	
   while (1){
	   GPIOB_ODR &= (~1);//0xfffffffe;
		int delay = 0x7ffff;
		while( delay -- > 0) ;
		GPIOB_ODR |= 1;
		delay = 0x7ffff;
		while( delay -- > 0) ;
		
   }
      ;
   return 0;
 }   

  

posted @ 2020-11-02 13:44  陆大逊  阅读(780)  评论(0)    收藏  举报