Modes of Operation

Normal Mode
The simplest mode of operation is the normal mode (WGM01:0 = 0). In this mode the counting direction is always up (incrementing), and no counter clear is performed. The counter simply overruns when it passes its maximum 8-bit value (TOP = 0xFF) and then restarts from the bottom (0x00). In normal operation the Timer/Counter overflow flag (TOV0) will be set in the same timer clock cycle as the TCNT0 becomes zero. The TOV0 flag in this case behaves like a ninth bit, except that it is only set, not cleared. However, combined with the timer overflow interrupt that automatically clears the TOV0 flag, the timer resolution can be increased by software. There are no special cases to consider in the normal mode, a new counter value can be written anytime.
The output compare unit can be used to generate interrupts at some given time. Using the output compare to generate waveforms in normal mode is not recommended, since this will occupy too much of the CPU time.
가장 단순한 작동은 노말모드 입니다 (WGM01:0 =0). 이 모드에서는 카운팅 방향은 항상 위쪽이며(증가), 카운터 클리어가 수행되지 않습니다. 카운터는 8bit 최대값을 넘어설때 (0xFF) 단순히 초과해 버리며 바닥(0x00) 부터 재시작 합니다. 


Clear Timer on Compare Match (CTC) Mode
In Clear Timer on Compare or CTC mode (WGM01:0 = 2), the OCR0 Register is used to manipulate the counter resolution. In CTC mode the counter is cleared to zero when the counter value(TCNT0) matches the OCR0. The OCR0 defines the top value for the counter, hence also its resolution. This mode allows greater control of the compare match output frequency. It also simplifies the operation of counting external events. The timing diagram for the CTC mode is shown in Figure 38. The counter value (TCNT0) increases until a compare match occurs between TCNT0 and OCR0, and then counter (TCNT0) is cleared. 
CTC 모드에서 OCR0 레지스터는 카운터 해상도를 조작하는데 사용됩니다. CTC 모드에서 카운터는 카운터 값(TCNT0)가 OCR0와 일치할때 0으로 초기화 됩니다. OCR0는 상한값과 해상도를 정의합니다. 이 모드는 compare match 출력 주파수의 더 나은 제어를 제공합니다. 그것은 또한 외부 이벤트의 카운팅 작업을 단순화 시킵니다. CTC 모드를 위한 타이밍 다이너그램은 Figure 38에 있습니다. 카운터 값(TCNT0)는 TCNT0와 OCR0 값이 일치하는 순간때까지 증가하며 카운터는(TCNT0) 초기화 됩니다.


Fast PWM Mode
The fast Pulse Width Modulation or fast PWM mode (WGM01:0 = 3) provides a high frequency PWM waveform generation option. The fast PWM differs from the other PWM option by its single-slope operation. The counter counts from BOTTOM to MAX then restarts from BOTTOM. In non-inverting Compare Output mode, the output compare (OC0) is cleared on the compare match between TCNT0 and OCR0, and set at BOTTOM. In inverting Compare Output mode, the output is set on compare match and cleared at BOTTOM. Due to the single-slope operation, the operating frequency of the fast PWM mode can be twice as high as the phase correct PWM mode that uses dual-slope operation. This high frequency makes the fast PWM mode well suited for power regulation, rectification, and DAC applications. High frequency allows physically small sized external components (coils, capacitors), and therefore reduces total system cost. In fast PWM mode, the counter is incremented until the counter value matches the MAX value. The counter is then cleared at the following timer clock cycle. The timing diagram for the fast PWM mode is shown in Figure 39. The TCNT0 value is in the timing diagram shown as a histogram for illustrating the single-slope operation. The diagram includes non-inverted and inverted PWM outputs. The small horizontal line marks on the TCNT0 slopes represent compare matches between OCR0 and TCNT0.
빠른 PWM 모드는 고주파 PWM 파형을 생성하는 옵션을 제공합니다. 빠른 PWM은 다른 PWM 옵션들에 비해 single-slope 작동으로 인해 차이점이 존재합니다. 카운터는 바닥에서 최대값으로 세고 바닥에서 다시 시작합니다(0 -> 0xFF / 증가).
non-inverting 비교 출력 모드에서는 출력비교(OC0)는 TCNT0와 OCR0가 일치할때 초기화 되고, 바닥(0x00)에서 설정됩니다.
inverting 비교 출력 모드에서는 일치할때 설정되고 바닥에서 초기화 됩니다. single-slope 작동으로 인해 빠른 PWM 모드의 작동 주파수는 dual-slope 작동을 사용하는 phase correct PWM의 2배 이상을 낼 수 있습니다. 이러한 높은 주파수로 인해 fast PWM 모드는 전력제어, 정류 그리고 DAC 어플리케이션에 매우 적절합니다. 고주파는 물리적으로 작은 크기의 외부 부품(코일, 캐패시터)를 사용할수 있도록 해주고, 전체 시스템의 비용을 낮출수 있습니다. 빠른 PWM 모드에서 카운터는 카운터 값이 최대값과 일치할때 까지 증가합니다. 카운터는 따라오는 타이머 클럭 사이클에 초기화 됩니다. 



Phase Correct PWM Mode
The phase correct PWM mode (WGM01:0 = 1) provides a high resolution phase correct PWM waveform generation option. The phase correct PWM mode is based on a dual-slope operation. The counter counts repeatedly from BOTTOM to MAX and then from MAX to BOTTOM. In non-inverting Compare Output mode, the output compare (OC0) is cleared on the compare match between TCNT0 and OCR0 while counting up, and set on the compare match while downcounting. In inverting Output Compare mode, the operation is inverted. The dual-slope operation has lower maximum operation frequency than single slope operation. However, due to the symmetric feature of the dual-slope PWM modes, these modes are preferred for motor control applications. 
phase correct PWM 모드는 고해상도의 
phase correct PWM 파형을 생성하는 옵션을 제공합니다. phase correct PWM 는 dual-slope 작동에 기반합니다. 카운터는 바닥과 최대값으로 그리고 최대에서 바닥으로 반복적으로 세어지게 됩니다. non-inverting비교 출력 모드에서는 출력 바교(OC0)는 숫자가 세어 올라가는(증가) 중 TCNT0와 OCR0이 일치하는 순간에 초기화 되고, 아래로 세어지는 도중(감소) 비교가 일치할 경우 설정됩니다. inverting  출력 비교 모드에서는 작동이 반대로 됩니다. dual-slope 작동은 single slope 작동보다 낮은 작동 주파수를 가집니다. 하지만 dual-slope PWM 모드의 대칭 특성으로 인해 모터 제어에 적합합니다.
Posted by 구차니