设为首页 加入收藏

TOP

STM32F4寄存器编写跑马灯例程(二)
2019-09-01 23:09:53 】 浏览:53
Tags:STM32F4 寄存器 编写 马灯
fine
GPIOA_PUPDR *(volatile unsigned long *)0x4002000C #define RCC_AHB1ENR *(volatile unsigned long *)0x40023830 #define GPIOA_BSRR *(volatile unsigned long *)0x40020018 //typedef struct //{ // __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ // __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ // __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ // __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ // __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ // __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ // __IO uint16_t BSRRL; /*!< GPIO port bit set/reset low register, Address offset: 0x18 */ // __IO uint16_t BSRRH; /*!< GPIO port bit set/reset high register, Address offset: 0x1A */ // __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ // __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ //} GPIO_TypeDef; void delay_ms(int time) { int i=8000*time; while(i--); } int main(void) { // delay_init(168); int i = 0, j = 0, k = 0; RCC_AHB1ENR |= 0x00000001; GPIOA_MODER &= ~((3<<(6*2))|(3<<(7*2))); GPIOA_MODER |= (1<< (6*2))|(1<<(7*2)); GPIOA_BSRR &= 0x0; //clear /* Speed mode configuration */ // GPIOA_OSPEEDR &= ~((3<<(6*2))|(3<<(7*2))); // GPIOA_OSPEEDR |= (3 << (6 * 2))|(3 << (7 * 2)); /* Output mode configuration*/ // GPIOA_OTYPER &= ~((3<<6)|(3<<7)) ; // GPIOA_OTYPER |= (0 << 6)|(0 << 7); /* Pull-up Pull down resistor configuration*/ // GPIOA_PUPDR &= ~((3<<(6*2))|(3<<(7*2))); // GPIOA_PUPDR |= (1<< (6*2))|(1<<(7*2)); // GPIOA_BSRRL = 0x0040|0x0080; while(1) { GPIOA_BSRR = (0x0040|0x0080)<<16; //reset delay_ms(1000); GPIOA_BSRR = 0x0040|0x0080; //set delay_ms(1000); } } void SystemInit() { ; }

以上代码便可以实现流水灯例子。

 
 

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇android 休眠唤醒机制分析(一) —.. 下一篇高通 NXP NFC(PN547PN548) 移植..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目