各位高手,我学习跑马灯寄存器实验,按录像做下载后发现延时有问题,500ms实际延时了5秒,改成50是500ms,不知怎么回事?请高手指点,谢谢!
#include "stm32f4xx.h"
#include "led.h"
#include "delay.h"
int main(void)
{
delay_init(168);
LED_Init();
while(1){
GPIOF->ODR &=~(1<<9);
GPIOF->ODR &=~(1<<10);
delay_ms(500);
GPIOF->ODR |= 1<<9;
GPIOF->ODR |= 1<<10;
delay_ms(500);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
#include "stm32f4xx.h"
void LED_Init(void)
{
RCC->AHB1ENR|= 1<<5;
//F9
GPIOF->MODER &= ~(3<<2*9);
GPIOF->MODER |= 1<<(2*9);
GPIOF->OSPEEDR &= ~(3<<2*9);
GPIOF->OSPEEDR |= 2<<(2*9);
GPIOF->PUPDR &= ~(3<<2*9);
GPIOF->PUPDR |= 1<<(2*9);
GPIOF->OTYPER &= ~(1<<9);
GPIOF->OTYPER |= 0<<9;
GPIOF->ODR |= 1<<9;
// GPIOF->ODR &=~(1<<9);
//F10
GPIOF->MODER &= ~(3<<2*10);
GPIOF->MODER |= 1<<(2*10);
GPIOF->OSPEEDR &= ~(3<<2*10);
GPIOF->OSPEEDR |= 2<<(2*10);
GPIOF->PUPDR &= ~(3<<2*10);
GPIOF->PUPDR |= 1<<(2*10);
GPIOF->OTYPER &= ~(1<<10);
GPIOF->OTYPER |= 0<<10;
GPIOF->ODR |= 1<<10;
}
高手,问下硬件的晶振在哪里配置?
一周热门 更多>