Skip to content

Instantly share code, notes, and snippets.

@Benargee
Created January 31, 2023 03:16
Show Gist options
  • Save Benargee/d06910770d7941859d431d5e1aeb6fff to your computer and use it in GitHub Desktop.
Save Benargee/d06910770d7941859d431d5e1aeb6fff to your computer and use it in GitHub Desktop.
Simple code to setup, increment and print Timer/Counter5 on pin47/PL2/T5
// Arduino Mega (2560) Platform.io
//Simple code to setup, increment and print Timer/Counter5 on pin47/PL2/T5
#include <Arduino.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
TCCR5A=0; //Timer/Counter 5 Control Register A
TCCR5B=0; //Timer/Counter 5 Control Register B
TCNT5=0; //Reset timer5 register value to 0
//Bit 2:0 – CSn2:0: Clock Select.
//7(b111): clock on rising edge.
//6(b110): clock on falling edge
TCCR5B = TCCR5B | 7;
}
void loop() {
// put your main code here, to run repeatedly:
uint16_t counter5 = TCNT5;
Serial.print("counter5: ");
Serial.println(counter5);
delay(1000);
}
@Benargee
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment