现在在做一个定时器的测试程序,要用定时器2定时1秒,中断中翻转IO口,改变指示灯状态。下面是我的程序:
#define ENCODER_TIM_PERIOD (u16) 13999
#define TIMx_Channel TIM2_IRQn
#define TIMx_PRE_EMPTION_PRIORITY 0
#define TIMx_SUB_PRIORITY 1
///
//u8 Port[1];//PCA9554D的端口
u8 act[5][10];//保存A,B,C,共补的电容器投切状态。
u8 counter;//临时程序试验用计数变量。
GPIO_InitTypeDef GPIO_InitStructure;
/* Private function prototypes -----------------------------------------------*/
void Switch_Twel(u8 flag );//正负12V输出电压转换及关闭prototypes
u8 Relay_Drive(u8 X,u8 Z);
void Relay_ALL_Leave(void);//切掉全部电容器。
/
/* Private functions ---------------------------------------------------------*/
void Delay100ms(void)
{
u32 cnt=0x00020000;
while(cnt--);//延时105ms
}
void GPIO_Ini(void)
{
/* GPIOA/GPIOB Periph clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB, ENABLE);
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
__NOP();
/* Configure PA8,PA0 ,PA12 in output pushpull mode *///指示灯控制
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_0|GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GP