简体   繁体   English

Timer1 中的“OCR1x 更新”是什么意思 - Atmega32

[英]What does the "Update of OCR1x" means in Timer1 - Atmega32

while going through the datasheet of the atmega32 , TIMER1 , modes of operation check the highlighted column in the image i added here在浏览 atmega32 的数据表 TIMER1 时,操作模式检查我在此处添加的图像中突出显示的列

1-I don't understand what "Update" means (highlighted in the image). 1-我不明白“更新”是什么意思(在图像中突出显示)。

2-What's meant by telling that the TOP value is fixed ??? 2-告诉TOP值是固定的是什么意思??? can't be changed in the runtime or something else ??不能在运行时更改或其他什么??

Answer 1 OCR1A and OCR1B are the pins that timer produces PWM on. Answer 1 OCR1A和OCR1B是定时器产生PWM的引脚。 This tells about when something happens to those pins.这说明了这些引脚何时发生了某些事情。 If you read the section before that shows the waveforms and explains the different counting it explains it pretty well.如果您阅读了之前显示波形并解释不同计数的部分,它会很好地解释它。 Depending on the mode, update is either toggle or set or clear.根据模式,更新是切换或设置或清除。

I'm looking at section 16.9 of the datasheet for the 328P.我正在查看 328P 数据表的第 16.9 节。 19.9.1 lists normal mode as all 3 bits 0, the top line in the chart. 19.9.1 将正常模式列为所有 3 位 0,即图表中的第一行。 It says that in normal mode counting is always up and overflows from TOP back to zero.它说在正常模式下计数总是向上并从 TOP 溢出回到零。 TOP is always at the max of the counter. TOP 总是在计数器的最大值处。 This is the simplest mode.这是最简单的模式。 In that mode the TOP value is OxFFFF (the MAX of the counter), and the PWM pins are updated immediately on a match with the compare register.在该模式下,TOP 值为 OxFFFF(计数器的最大值),PWM 引脚在与比较寄存器匹配时立即更新。 The overflow flag is set at MAX, which is 0xFFFF for this timer.溢出标志设置为 MAX,该定时器为 0xFFFF。

It also describes CTC mode where the TOP value is set with one of the registers.它还描述了使用寄存器之一设置 TOP 值的 CTC 模式。 And then it describes the different PWM modes and how they use TOP and BOTTOM and when they update.然后描述了不同的 PWM 模式以及它们如何使用 TOP 和 BOTTOM 以及它们何时更新。 It's really more than I can reproduce here on this answer.这真的比我在这个答案中可以重现的要多。

As one more example look at mode 1. That's a phase correct mode which according to section 16.9.4 means that the counter is counting from BOTTOM to TOP and then back down again.再举一个例子,看看模式 1。这是一种相位校正模式,根据第 16.9.4 节,这意味着计数器从 BOTTOM 到 TOP 计数,然后再次向下计数。 Looks like in mode 1 the TOP value is 0x00FF so it's an 8 bit timer.看起来在模式 1 中,TOP 值是 0x00FF,所以它是一个 8 位定时器。 It updates the pin at TOP (and at compare match).它更新 TOP 处的引脚(以及比较匹配处)。 If you read that section it explains how that affects the PWM pulses.如果您阅读该部分,它会解释这如何影响 PWM 脉冲。 It also says that it sets the overflow flag at BOTTOM, which makes sense because that is one full cycle of the timer.它还说它在底部设置了溢出标志,这是有道理的,因为这是定时器的一个完整周期。

Answer 2 If the top value is fixed then yes you can't change it.答案 2 如果最高值是固定的,那么是的,您无法更改它。 There are some modes where you can set the top value using one of the other registers.在某些模式下,您可以使用其他寄存器之一设置最高值。 There are some modes where you can't.有一些模式你不能。 Again, the sections before all explain pretty well how all those different modes work.同样,前面的部分很好地解释了所有这些不同模式的工作原理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM