Timer1 Compare Match  ver.1.0
Nguyen 2016
Functions
start.cpp File Reference

Hauptprogramm (Arduino Style) More...

#include <Arduino.h>
#include "_debug.h"

Go to the source code of this file.

Functions

void setup ()
 
 ISR (TIMER1_COMPA_vect)
 
void loop ()
 

Detailed Description

Hauptprogramm (Arduino Style)

Counter Compare Match Interrupt (ATMEGA 328p 16Mhz)

Author
Nguyen 2016 4AHEL
Date
29.01.16
Version
1.0

Aufgabenstellung

Timer 1 Counter Compare match erzeugt Taktsignal; Periodendauer in ms über die Pins PB2/PB1/PB0 konfigurierbar.

Das HIGH Byte des Compare-Registers liegt an PortC an, das Low Byte ist immer Null. Bei jedem Compare Match Interrupt soll PB3 togglen.

Berechnung der Periodendauer

schnellstes Signal ist bei 0 Precale = 62,5ns OCR1A = 0x0000 => die Berechnung ist nicht möglich; der Interrupt wird bei jedem Zyklus ausgeführt, Aufruf der ISR und Rückkehr dauert aber 80 Zyklen lang ==> 4.7uS pro Einsprung in die ISR langsamstes signal bei prescale von 1024 –> 62,5ns*1024 =64µs OCR1A = 0x7fff (PORTC hat keinen PIN7, daher ist 7F der höchste Wert, der am Port C eingestellt werden kann) ==> 64us * 32000 ~ 2s ==> 4S Periodendauer (2x ISR)

Definition in file start.cpp.

Function Documentation

ISR ( TIMER1_COMPA_vect  )

togglet den Pin PB3

Definition at line 117 of file start.cpp.

void loop ( )

do nothing

Definition at line 124 of file start.cpp.

void setup ( )

Configure

  • Ports
  • Timer1
    • CTC Mode
    • Prescaler
    • Compare Match Interrupt

Definition at line 42 of file start.cpp.