本帖最后由 vinshen 于 2013-5-23 14:39 编辑
Hi!all
i plan to light 8 led ,but only 4 can be actived.which wrong??
#include "stm32f4xx.h"
uint32_t Gb_TimingDelay;
⋯⋯ void Delay( uint32_t nTime);
int main(void)
{
SysTick_Config(SystemCoreClock/1000);
RCC->AHB1ENR|=(1<3); gpiod output
RCC->APB2ENR|=(1<<14);
GPIOD->MODER &= 0X0000ffff; //setup pin8-15 output
GPIOD->MODER |= 0X55550000; //form reference
GPIOD->OTYPER &= 0X0000ffff; //pushup
GPIOD->OSPEEDR &= 0X0000ffff;//PD8 9 10 11 12 13 14 15
GPIOD->OSPEEDR |= 0Xffff0000;
while(1)
{
int i;
for(i=0;i<8;i++){
GPIOD->BSRRH=0Xff00;
GPIOD->BSRRL=~(0X0100<i);
Delay(500);
}
}
void Delay(uint32_t nTime)
{
Gb_TimingDelay = nTime;
while(Gb_TimingDelay != 0X00);
}
void SysTick_Handler(void)
{
if (Gb_TimingDelay!=0x00)
{
Gb_TimingDelay--;
}
} |