IT / / 2020. 4. 28. 19:43

ATmega128 8-bit 타이머/카운터 데이터 시트 해석

반응형

Modes of Operation(작동모드)

The mode of operation, i.e., the behavior of the Timer/Counter and the output compare pins, is defined by the combination of the Waveform Generation mode (WGM01:0) and Compare Output mode (COM01:0) bits.
(작동모드, 즉 타이머/카운터 및 출력 비교 핀의 동작은 파형 생성모드와 출력비교 조합에 의해 정의된다.)

The Compare Output mode bits do not affect the counting sequence, while the Waveform Generation mode bits do. (출력비교모드 비트는 카운팅시퀸스에 영향을 주지 않는 반면 파형생성모드 비트는 영향을 미친다.)

The COM01:0 bits control whether the PWM output generated should be inverted or not (inverted or non-inverted PWM).(COM01:0 비트는 생성된 PWM 출력이 반전되어야 하는지 여부를 제어한다(반전 또는 비반전 PWM).)

For non-PWM modes the COM01:0 bits control whether the output should be set, cleared, or toggled at a compare match(비 PWM 모드의 경우 COM01:0 비트는 비교 일치에서 출력을 설정, 삭제 또는 토글할지 여부를 제어한다.)

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).(카운터는 최대 8비트 값(TOP = 0xFF)을 통과한 다음 하단(0x00)에서 다시 시작하면 오버런만 발생하게 된다.)

In normal operation the Timer/Counter overflow flag (TOV0) will be set in the same timer clock cycle as the TCNT0 becomes zero.(정상 작동 시 TIMER/Counter Overflow 플래그(TOV0)는 TCNT0이 0이 되는 것과 동일한 타이머 클럭 사이클로 설정된다.)

 The TOV0 flag in this case behaves like a ninth bit, except that it is only set, not cleared.
(이 경우 TOV0 플래그는 9번째 비트처럼 동작하지만, 설정만 되어 있고 지워지지 않는다.)

However, combined with the timer overflow interrupt that automatically clears the TOV0 flag, the timer resolution can be increased by software.(그러나 타이머 오버플로 인터럽트와 결합됨 TOV0 플래그를 자동으로 지우는 소프트웨어로 타이머 해상도를 높일 수 있다.)

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.
(출력 비교 장치는 특정 시간에 인터럽트를 발생시키는 데 사용할 수 있다. 출력 비교를 사용하여 정상 모드에서 파형을 생성하는 것은 권장되지 않는다. 이는 CPU 시간을 너무 많이 차지하기 때문이다.)

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.(비교 또는 CTC 모드에서 타이머 지우기 (WGM01 : 0 = 2)에서 OCR0 레지스터는 카운터 해상도를 조작하는 데 사용됩니다.)

In CTC mode the counter is cleared to zero when the counter value (TCNT0) matches the OCR0.
(CTC 모드에서 카운터 값은 카운터 값이 0 일 때 클리어됩니다 (TCNT0)은 OCR0과 일치합니다.)

The OCR0 defines the top value for the counter, hence also its resolution.
(OCR0은 카운터의 최상위 값을 정의하므로 해상도도 결정됩니다.)

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 모드의 타이밍 다이어그램은 그림 38에 표시되어 있습니다.
카운터 값 (TCNT0)은 TCNT0과 OCR0간에 비교 일치가 발생할 때까지 증가한 다음 카운터 (TCNT0)가 지워집니다.)

Figure 38. CTC Mode, Timing Diagram

An interrupt can be generated each time the counter value reaches the TOP value by using the OCF0 flag.
(OCF0 플래그를 사용하여 카운터 값이 TOP 값에 도달 할 때마다 인터럽트가 생성 될 수 있습니다.)

If the interrupt is enabled, the interrupt handler routine can be used for updating the TOP value.
(인터럽트가 사용 가능한 경우 인터럽트 핸들러 루틴을 사용하여 TOP 값을 업데이트 할 수 있습니다.)

However, changing the TOP to a value close to BOTTOM when the counter is running with none or a low prescaler value must be done with care since the CTC mode does not have the double buffering feature.
(그러나 CTC 모드에는 이중 버퍼링 기능이 없으므로 카운터가 없거나 낮은 프리스케일러 값으로 카운터를 실행할 때 TOP을 BOTTOM에 가까운 값으로 변경해야합니다.)

 If the new value written to OCR0 is lower than the current value of TCNT0, the counter will miss the compare match.(OCR0에 기록 된 새 값이 현재 TCNT0 값보다 낮은 경우 카운터는 비교 일치를 놓치게됩니다.)

 

반응형
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유