#include <stm32f4xx.h>
uint32_t Gb_TimingDelay=100;
void Delay(uint32_t nTime);
int main ()
{
SysTick_Config(SystemCoreClock/1000); // 设置 systemtick 一毫秒中断
RCC->AHB1ENR|= 0x00000008; // 使能GPIOD 时钟
RCC->APB2ENR|= (1<<14); // 使能syscfg 时钟
GPIOD->MODER&=0x00FFFFFF; // 设置 PD12,13,14,15 输出
GPIOD->MODER|=0x55000000;
GPIOD->OTYPER&=0xFFFF0FFF; // 设置PD12,13,14,15 推挽输
GPIOD->OSPEEDR&=0x00FFFFFF; //PD12,13,14,15 速度100m
GPIOD->OSPEEDR|=0xff000000;
SYSCFG->CMPCR=0x00000001; // 使用IO 补偿单元,
// 当GPIO速度超过 50M 的时候要考虑使用此设置
GPIOD->
UPDR&=0x00FFFFFF; //PD12,13,14,15 无上拉无下拉
GPIOD->BSRRH=0xf000;//reset register GPIOx_BSRRH, write only
//set register GPIOx_BSRRL, write only
while(1)
{
GPIOD->BSRRH=0xf000;
GPIOD->BSRRL=0x1000;
Delay(500);
GPIOD->BSRRH=0xf000;
GPIOD->BSRRL=0x1000<<1;
Delay(500);
GPIOD->BSRRH=0xf000;
GPIOD->BSRRL=0x1000<<2;
Delay(500);
GPIOD->BSRRH=0xf000;
GPIOD->BSRRL=0x1000<<3;
Delay(500);
}
}
void Delay(uint32_t nTime)
{
Gb_TimingDelay=nTime;
while(Gb_TimingDelay!=0);
}
void SysTick_Handler(void)
{
if(Gb_TimingDelay!=0x00)
{
Gb_TimingDelay -- ;
}
}
---------------------------------
哪你问老师要一个例子程序呀,先跟着例子跑跑看。
一周热门 更多>