Microchip
直播中

张杰

7年用户 1309经验值
私信 关注
[问答]

使用Atmega328p改变快速PWM频率和占空比

大家好,所以我一直在通过ATMEGA328 P数据表,我一直在尝试每一个由微控制器提供的功能。碰巧我正在做计时器/计数器的功能。现在使用time0(8位定时器),我能够产生PWM信号,设置频率(使用预分频),并改变占空比(使用OCRA0比较匹配)。这是在波形生成模式的模式3中完成的。在该模式中,顶部值为0xFF(255),底部值为0x00(0)。现在在模式7中,顶部值是OcRA0。通过这种模式,您应该能够通过更新OCRA0注册表来改变频率,并且我猜想可以使用中断服务程序来完成,但我正在尝试找出如何改变占空比。在这个模式下,我看不到在数据表中做这件事的任何方向(我不知道我是否忽略了它)。有人知道该怎么办吗?

以上来自于百度翻译


      以下为原文

    Hello everyone, so I have been going through the Atmega328p datasheet and I have been trying to go over every feature provided by the micro-controller. It so happens that I am working on the Timer/Counter features. Now using the Timer0 (8 bit timer) I was able to produce a PWM signal, set the frequency (using prescale), and change the duty cycle (using OCRA0 compare matches). This was done in mode 3 of the Waveform Generation Modes. In this mode the TOP value is 0xFF (255) and BOTTOM value  is 0x00(0). Now in mode 7, the TOP value is OCRA0. With this mode you should be able to change the frequency by updating the OCRA0 registry and I am guessing that can be done using an Interrupt Service Routine, but I am trying to figure out how to change the duty cycle. I don't see any direction of doing this in the datasheet while in this mode (I don't know if I overlooked it). Anyone knows about how to go about this?

回帖(1)

吴键洪

2018-10-29 11:24:01
是的,Microchip已经购买了Atmel,但是他们还没有把支持william hill官网 结合起来。你只需要在这里找到PIC专家。我建议你看一下HTTPS://Culial.AtMEL.COM/

以上来自于百度翻译


      以下为原文

    Yes, Microchip have bought Atmel, but they have not combined the support forums yet.
You're only going to find PIC experts here.
 
I suggest you have a look at https://community.atmel.com/
 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分