用的库,应该说中断过程就这么简单,但就是不知道为什么只能进一次中断,各位有时间的路过的看下,随便帮个忙找找问题?
#include "stm8l15x.h"
////////////延时函数
void delay(int i)
{ int j;
for(j=0;j<i;j++)
{;}
}
void CLK_Init(void)
{
CLK_DeInit();
/* High speed internal clock prescaler: 1 */
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
/* Enable TIM4 CLK */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE);
}
void IO_Init(void)
{
GPIO_DeInit(GPIOE);
GPIO_Init(GPIOE, GPIO_Pin_7, GPIO_Mode_Out_PP_Low_Fast);
GPIO_Write(GPIOE,0xf0);
}
void TIM4_Config(void)
{
TIM4_TimeBaseInit(TIM4_Prescaler_128, 0x7c);
/* Clear TIM4 update flag */
TIM4_ClearFlag(TIM4_FLAG_Update);
/* Enable update interrupt */
TIM4_ITConfig(TIM4_IT_Update, ENABLE);
/* Enable TIM4 */
TIM4_Cmd(ENABLE);
}
void main()
{
IO_Init();
CLK_Init();
TIM4_Config();
/* enable interrupts */
enableInterrupts();
while (1)
{
;
}
}
这是中断函数:
INTERRUPT_HANDLER(TIM4_UPD_OVF_TRG_IRQHandler,25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
u16 count=0 ;
// GPIO_Write(GPIOE,0x00);
TIM4_ClearITPendingBit(TIM4_IT_Update);
count++;
if(count>1000)
{
GPIO_ToggleBits(GPIOE,GPIO_Pin_7);
count=0;
}
}
|