ch552使用两个定时器是,程序出现两个定时器中断函数为什么是不可以,求解一下

一个控制定时器0中断,一个控制定时器1中断,遇到问题是两个中断不能同事存在,想了解是什么问题

1642125878(1).png



描述问题


定时器0和1两个中断同时存在,不能进行编译,只有一个中断存(另一个需要注解)在才可以,这是为什么?


well its a bad idea in most cases to call functions inside irq routines. This is especially true wenn you are using the using xx clause. In your case its even more bad since you are using aTimer_x_SetData in main context as well as in irq timer0 context. 

This should produce at least a warning.


I dont see any TF0=0; or TF1=0; insite the IRQ routines to clear that irq flags. Therefore T0 irq is called again and again.


@usbman,CH552's time irq flag can be clear automaticly when jump into irq function,as described in the manual.

image.png

不能进行编译和编译出错是两种情况,我们关注一下错误信息。

编译软件不会关心代码直接是否对应现实运行结果。只要没有语法错误,就应该能够编译。

所以请确认


已经解决了



只有登录才能回复,可以选择微信账号登录