用的是STM8L151K6单片机
发现定时器不能中断,代码如下
extern @far @interrupt void time2_IRQHandler(void);
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)main}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, NonHandledInterrupt}, /* irq5 */
{0x82, NonHandledInterrupt}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, NonHandledInterrupt}, /* irq11 */
{0x82, NonHandledInterrupt}, /* irq12 */
{0x82, time2_IRQHandler}, /* irq13 */
{0x82, NonHandledInterrupt}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, NonHandledInterrupt}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, NonHandledInterrupt}, /* irq22 */
{0x82, NonHandledInterrupt}, /* irq23 */
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
};
@far @interrupt void time2_IRQHandler(void)
{
RCRST_1;
TIM2_SR1 &= ~0x01; //清除中断标记
RTC_FLOW_FLAG = 1;
return;
}
void sys_ini(void)
{
unsigned char i;
CLK_ICKCR |= 0X01; //打开内部HSI时钟
while(!(CLK_ICKCR & 0X02)); //等待内部时钟稳定
CLK_CKDIVR = 0x12; //0x1a; //
CLK_CSSR = 0X00;
TIM2_IER = 0X00; //先禁止中断
TIM2_EGR = 0X01; //允许产生更新事件
TIM2_PSCR = 0X04;
TIM2_ARRH = RTCH_SET; //设置定时
TIM2_ARRL = RTCL_SET;
TIM2_CNTRH = RTCH_SET;
TIM2_CNTRL = RTCL_SET;
TIM2_CR1 |= 0X81; //开启定时器时间初始值
TIM2_IER |= 0X01; //允许更新中断
_asm("rim"); //允许CPU全局中断
}
已经搞了一个星期了,真的要崩溃了。是我的技术太菜了吗?确实是刚接触STM。哎!请高手指点一下啊
extern @far @interrupt void time2_IRQHandler(void);有声明的,这个声明在STM_INTERRUUT_VECTOR.C中
现在怎么查到TIM2的向量呢??看了STM8L的参考文档里也没有。请高手指教一下啊! |
|