IM_Cmd(TIM3, ENABLE);
}
void song()
{
// TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
// TIM_TimeBaseStructure.TIM_Period = reload_time;
// reload_time=FREQH[k]*256+FREQL[k];
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
reload_time=get_time;
TIM_TimeBaseStructure.TIM_Period = reload_time;
TIM_Cmd(TIM3, ENABLE);
delay(time);
}
int main (void)
{
uchar i=0;
RCC_Configuration(); //配置时钟
NVIC_Configuration();
GPIO_Configuration(); //配置IO口
TIM3_Configuration();
GPIO_WriteBit(GPIOD, GPIO_Pin_9, (BitAction)1);
GPIO_WriteBit(GPIOB, GPIO_Pin_5, (BitAction)1);
delay1(10);
GPIO_WriteBit(GPIOD, GPIO_Pin_9, (BitAction)0);
GPIO_WriteBit(GPIOB, GPIO_Pin_5, (BitAction)0);
while(1)
{
time=1;
i=0;
while(i<75)
{
k=sszymmh[i]+7*sszymmh[i+1]-1;
get_time=FREQH[k]*256+FREQL[k];
time = sszymmh [i+ 2]; //读出时间长度数值
i=i+3;
song();
}
}}
void TIM3_IRQHandler (void)
{
// TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_Cmd(TIM3, DISABLE);
if(TIM_GetITStatus(TIM3,TIM_IT_Update)!=RESET)//判断是否为定时器3溢出中断
{
(bool)beep=!beep;
reload_time=get_time;
GPIO_WriteBit(GPIOB, GPIO_Pin_5, (BitAction)beep);
GPIO_WriteBit(GPIOD, GPIO_Pin_9, (BitAction)beep);
}
TIM_ClearFlag(TIM3, TIM_FLAG_Update); //清中断标记
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
// TIM_Cmd(TIM3, DISABLE);
}