在线时间0 小时
UID321135
ST金币0
蝴蝶豆0
注册时间2008-1-28
新手上路
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2011-10-6 17:02:41
|
显示全部楼层
a0a.1 0b0c
RE:现有项目求大侠指点!有偿帮助!谢谢
void SystemInit (void)
{
/*!< RCC system reset(for debug purpose) */
/*!< Set HSION bit */
RCC->CR |= (uint32_t)0x00000001;
/*!< Reset SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], ADCPRE[1:0] and MCO[2:0] bits */
RCC->CFGR &= (uint32_t)0xF8FF0000;
/*!< Reset HSEON, CSSON and PLLON bits */
RCC->CR &= (uint32_t)0xFEF6FFFF;
/*!< Reset HSEBYP bit */
RCC->CR &= (uint32_t)0xFFFBFFFF;
/*!< Reset PLLSRC, PLLXTPRE, PLLMUL[3:0] and USBPRE bits */
RCC->CFGR &= (uint32_t)0xFF80FFFF;
/*!< Disable all interrupts */
RCC->CIR = 0x00000000;
/*!< Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */
/*!< Configure the Flash Latency cycles and enable prefetch buffer */
//SetSysClock(); //我屏蔽了这句晶振脚就有波形了,奇怪,但LED还是没亮
}大侠能否帮我看下原因,下面是LED的程序看是否正确,
int main(void)
{
u32 cnt = 0x000fffff;
/* System Clocks Configuration */
RCC_Configuration();
/* Configure the GPIO ports */
GPIO_Configuration();
led_status = LED1;
while (1){
switch (led_status){
case LED1:
//GPIOB->BSRR = 0x1000E000; /* turn on LD1 */
GPIOA->BSRR = 0x00000002; //PA1,输出高电平LED就亮,低电平就灭
led_status = LED2;
break;
case LED2:
//GPIOB->BSRR = 0x2000D000; /* turn on LD2 */
GPIOA->BSRR = 0x20000000;
led_status = LED3;
break;
case LED3:
//GPIOB->BSRR = 0x4000B000; /* turn on LD3 */
GPIOA->BSRR = 0x00000002;
led_status = LED4;
break;
case LED4:
//GPIOB->BSRR = 0x80007000; /* turn on LD4 */
GPIOA->BSRR = 0x20000000;
led_status = LED1;
break;
}
while(cnt--);
cnt = 0x000fffff;
}
}
void RCC_Configuration(void)
{
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
SystemInit();
/* GPIOA clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOB configuration: PB12 PB13 PB14 PB15 as led controller */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//GPIO_Mode_Out_PP,GPIO_Mode_Out_OD
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
} |
|