From d6c0398f3db7215da5a084daaf82ecda85fef9d2 Mon Sep 17 00:00:00 2001 From: Josarn Date: Wed, 25 Apr 2018 17:16:05 +0200 Subject: [PATCH] atmega timer: Interrupt Pin A debug pin can be used to probe timer interrupts with an oscilloscope or other time measurement equipment. Thus, determine when an interrupt occurs and how long the timer ISR takes. The pin should be defined in the makefile as follows: CFLAGS += -DDEBUG_TIMER_PORT=PORTF -DDEBUG_TIMER_DDR=DDRF \ -DDEBUG_TIMER_PIN=PORTF4 --- cpu/atmega_common/periph/timer.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cpu/atmega_common/periph/timer.c b/cpu/atmega_common/periph/timer.c index 4a0065fde3b5..cc420fd85153 100644 --- a/cpu/atmega_common/periph/timer.c +++ b/cpu/atmega_common/periph/timer.c @@ -83,6 +83,21 @@ static ctx_t ctx[] = { */ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg) { +/* + * A debug pin can be used to probe timer interrupts with an oscilloscope or + * other time measurement equipment. Thus, determine when an interrupt occurs + * and how long the timer ISR takes. + * The pin should be defined in the makefile as follows: + * CFLAGS += -DDEBUG_TIMER_PORT=PORTF -DDEBUG_TIMER_DDR=DDRF \ + * -DDEBUG_TIMER_PIN=PORTF4 + */ +#if defined(DEBUG_TIMER_PORT) + DEBUG_TIMER_DDR |= (1 << DEBUG_TIMER_PIN); + DEBUG_TIMER_PORT &= ~(1 << DEBUG_TIMER_PIN); + DEBUG("Debug Pin: DDR 0x%02x Port 0x%02x Pin 0x%02x\n", + &DEBUG_TIMER_DDR , &DEBUG_TIMER_PORT,(1<