From 7b006d6f2032ac46074d693ae59a971bee327ace Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Fri, 9 Sep 2022 18:33:15 -0500 Subject: init --- src/debug.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/debug.c (limited to 'src/debug.c') diff --git a/src/debug.c b/src/debug.c new file mode 100644 index 0000000..858195e --- /dev/null +++ b/src/debug.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include "debug.h" + + + + + +/* + * TCNTn: timer/counter + * TCCRnA/B/C: timer/counter control registers + */ +void timer_init() { + TCCR1A = 0; //no waveform generation or something like that + TCCR1B = _BV(CS00); //no prescaling; use internal clock + TCCR1C = 0; +} + +//makes it easier to print time; is an unsigned int and NOT to be used for more then printing +unsigned int ticks_to_seconds(uint16_t start, uint16_t end) { + return ((unsigned int)(end - start) / F_CPU); +} + +void test_timer() { + uint16_t start, end; + start = TCNT1; + _delay_ms(1000); + end = TCNT1; + printf("1 second is %u ticks\n", end - start); +} -- cgit v1.2.3