cailuqijia 发表于 2008-4-29 08:24:56

AVR单片机中如何使各个定时器同步工作?

AVR单片机中如何使各个定时器同步工作?我看了AVR单片机通用定时/计数器,好象没有介绍如何使他们同步工作.我主要用他们来产生不同占空比的PWM,但必须要有一个同步计数时基.当然也可用一个定时器在不同的时间预定标处设定标志位,通过软件查询标志位用通用IO口输出高低变换PWM.但是对软件产生PWM我本人不敢恭维.总是没有硬件产生PWM好.能不能设置一个全局总标志位,通过查询状态,同时启动所有定时器?不知马老师有什么好建议?

machao 发表于 2008-4-29 15:00:22

下面是M16中于T/C0 和T/C1相关的一个控制位,利用它可以实现你的想法.具体可查看M16的手册,对照T/C0和T/C1的预分频器原理图,看看如何使用SFIOR中的PSR10控制位.供参考

Special Function IO Register –SFIOR

• Bit 0 – PSR10: Prescaler Reset Timer/Counter1 and Timer/Counter0

When this bit is written to one, the Timer/Counter1 and Timer/Counter0 prescaler will be reset. The bit will be cleared by hardware after the operation is performed. Writing a zero to this bit will have no effect. Note that Timer/Counter1 and Timer/Counter0 share the same prescaler and a reset of this prescaler will affect both timers. This bit will always be read as zero.

wisebaby 发表于 2008-5-7 14:33:23

这个。。

我也努力在学。。
页: [1]
查看完整版本: AVR单片机中如何使各个定时器同步工作?