在线时间0 小时
UID309350
ST金币0
蝴蝶豆0
注册时间2011-7-31
新手上路
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
用的固件库,调试的时候看了TIM1的寄存器配置都没错,就是不进入中断。。。。不知道是什么原因?
main.c中的程序:
/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
#include "stm8s_it.h"
#define LED_PORT (GPIOD)
#define LED1_PIN (GPIO_PIN_3)
#define LED2_PIN (GPIO_PIN_2)
#define LED3_PIN (GPIO_PIN_0)
#define BUTTON_PORT (GPIOD)
#define BUTTON_PIN (GPIO_PIN_7)
void GPIOInit(void)
{
/* Infinite loop */
GPIO_Init(LED_PORT, LED1_PIN,GPIO_MODE_OUT_PP_LOW_SLOW);
}
void TIM1Init(void)
{
TIM1_TimeBaseInit( 0x1F3F,0x10,0x01F4,0x01F4);
/*PSCR=0x1F3F,f=8M/(0x1F3F+1)=1000Hz,每个计数周期1ms
计数器使能,开始计数
每记数500次产生一次中断,即500ms*/
TIM1_ITConfig(TIM1_IT_UPDATE, ENABLE);
TIM1_Cmd(ENABLE);
/*允许更新中断*/
}
void main(void)
{
GPIOInit();
TIM1Init();
while(1)
{
}
}
stm8_it.c中的程序部分:
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
GPIO_WriteReverse(LED_PORT, LED1_PIN);
TIM1_ClearFlag(TIM1_FLAG_UPDATE); // 清除更新中断标记
i++;
}
|
|