请问下面这段程序有什么问题?在mini开发板上就是没有效果,
#include"stm32f10x.h"
//ALIENTEK Mini STM32¿a·¢°å·¶ày′úÂë7
//¶¨ê±Æ÷ÖD¶ÏêμÑé
//¼¼êõÖ§3Ö£o
www.openedv.com
//1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOD , ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
}
void TIM3_Init(void) //¶¨ê±3õê¼»ˉ
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
TIM_TimeBaseStructure.TIM_Period = 9999;
TIM_TimeBaseStructure.TIM_Prescaler =7199;
TIM_TimeBaseStructure.TIM_ClockDivision = 0; //
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//ÏòéϼÆêy
TIM_TimeBaseInit(TIM3, & TIM_TimeBaseStructure);
TIM_ITConfig(TIM3,TIM_IT_Update, ENABLE ); //ê1ÄütimÖD¶Ï
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStructure.NVIC_IRQChannel=TIM3_IRQn; //ÖD¶ÏóÅÏ輶ÅäÖÃ
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=1;
TIM_Cmd(TIM3, ENABLE); //′ò¿atim3ÖD¶Ï
}
void TIM3_IRQHandler(void)
{
if(TIM_GetITStatus(TIM3, TIM_IT_Update) == SET)
{
GPIO_SetBits(GPIOA, GPIO_Pin_8);
GPIO_SetBits(GPIOD, GPIO_Pin_2);
TIM_ClearITPendingBit(TIM3,TIM_IT_Update);
}
}
int main(void)
{
LED_Init();
TIM3_Init();
while(1)
{
GPIO_ResetBits(GPIOA, GPIO_Pin_8);
GPIO_ResetBits(GPIOD, GPIO_Pin_2);
}
}
一周热门 更多>