流水灯做成了,但我想让他全亮全灭弄不通:
#include "stm32f10x.h"
/**
* @brief Ö÷oˉêy
* @param ÎT
* @retval ÎT
*/
#define LED1_TOGGLE GPIOA->ODR^=GPIO_Pin_0
#define LED1_OFF GPIOA->BSRR = GPIO_Pin_0
#define LED1_ON GPIOA->BRR = GPIO_Pin_0
#define LED2_TOGGLE GPIOA->ODR^=GPIO_Pin_1
#define LED2_OFF GPIOA->BSRR = GPIO_Pin_1
#define LED2_ON GPIOA->BRR = GPIO_Pin_1
#define LED3_TOGGLE GPIOA->ODR^=GPIO_Pin_2
#define LED3_OFF GPIOA->BSRR = GPIO_Pin_2
#define LED3_ON GPIOA->BRR = GPIO_Pin_2
#define LED4_TOGGLE GPIOA->ODR^=GPIO_Pin_3
#define LED4_OFF GPIOA->BSRR = GPIO_Pin_3
#define LED4_ON GPIOA->BRR = GPIO_Pin_3
//ê1óÿaoˉêy
#define LED5_OFF GPIO_SetBits(GPIOA,GPIO_Pin_4)
#define LED5_ON GPIO_ResetBits(GPIOA,GPIO_Pin_4)
#define LED6_OFF GPIO_SetBits(GPIOA,GPIO_Pin_5)
#define LED6_ON GPIO_ResetBits(GPIOA,GPIO_Pin_5)
#define LED7_OFF GPIO_SetBits(GPIOA,GPIO_Pin_6)
#define LED7_ON GPIO_ResetBits(GPIOA,GPIO_Pin_6)
#define LEDALL_OFF GPIO_SetBits(GPIOA,GPIO_Pin_All)
#define LEDALL_ON GPIO_ResetBits(GPIOA,GPIO_Pin_All)
void LED_Cfg(void){
GPIO_InitTypeDef led_gpio;
SystemInit();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
led_gpio.GPIO_Pin = GPIO_Pin_All;
//led_gpio.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3
// | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
led_gpio.GPIO_Mode = GPIO_Mode_Out_PP;//í¨óøøíÆíìêä3ö
led_gpio.GPIO_Speed = GPIO_Speed_50MHz;//2MHz
GPIO_Init(GPIOA,&led_gpio);
//ÅäÖÃíê3éoó1رÕËùóDLED
LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
LED5_OFF;
LED6_OFF;
LED7_OFF;
LEDALL_OFF;
}
void Delay(u32 nCount){
while(nCount--);
}
int main(void)
{
LED_Cfg();
while(1){
LEDALL_ON; Delay(6000000);
LEDALL_OFF;
Delay(6000000); 烧录这个程序流水灯不亮

但以下这个就可以亮
/*LED1_ON;
LED2_ON;
LED3_ON;
LED4_ON;
LED5_ON;
LED6_ON;
LED7_ON;
Delay(6000000);
LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
LED5_OFF;
LED6_OFF;
LED7_OFF;
Delay(6000000);*/

}
}
|