-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
atmega timer: Interrupt Pin #9025
Conversation
@aabadie could you have a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpu/atmega_common/periph/timer.c
Outdated
@@ -169,6 +193,10 @@ void timer_start(tim_t tim) | |||
#ifdef TIMER_NUMOF | |||
static inline void _isr(tim_t tim, int chan) | |||
{ | |||
#if defined(DEBUG_TIMER_PORT) | |||
DEBUG_TIMER_PORT |= (1 << DEBUG_TIMER_PIN); | |||
DEBUG_TIMER_PORT &= ~(1 << DEBUG_TIMER_PIN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You you stated in the initial comment to measure the duration of the ISR. I'm imagining a pulse that is high until the CPU has left the ISR. Shouldn't this line be placed after __exit_isr() to achieve that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@A-Paul thank you for that. Your asumption is correct and it was implemented like this at the beginning.
As the context swap of the atmegas was changed to also execute in interrupts setting the pin to low would now happen after the context comes back the context which was active when the interrupt was triggered so it would not executed in the right time. I changed the debug pin to only signilizes the start of the timer interrupt. And forgott to update the documentation.
I change the pin toggle to be executed before the context swap, thus the documentation fits the function, only that the context swap is not included in the high period anymore.
Squash and rebase? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Josar, there is somthing i missed in my first review.
cpu/atmega_common/periph/timer.c
Outdated
* CFLAGS += -DDEBUG_TIMER_DDR=DDRF | ||
* CFLAGS += -DDEBUG_TIMER_PIN=PORTF4 | ||
*/ | ||
#if defined(DEBUG_TIMER_PORT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"board.h" is already included in line 25.
@PeterKietzmann done |
I wiil do a HW test tomorrow. |
Hi @Josar , I have built and run some of the tests/xtimer_* on a arduino-mega2560 and connected to an oscilloscope. Works like it is supposed. |
@A-Paul i had a quick view over the approach from #7352. And yes it seems more generalized, but it is also on halt for quite a while. One other thing is that if it is used like this it is not flexible anymore. Means if i use e.g. This Approach defines a well defined PIN for a single action e.g. Timer, This can be freely set to a pin. I am not in favor of the generalized approach shown in #7352 for a low level driver debug pin solution. The generelized approach could be something which could be used in application level as shown here https://github.com/RIOT-OS/RIOT/pull/8865/files. |
@Josar thank you for you investigation. I will follow you reasoning and merge, but I have a last change request. I'll place it in a review comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last code change left the config explanation (lines 35-47) standing alone. Putting it above the initialization as a replacement of line 99 would be more sensible.
It also requires a lot space and has some redundant infos.
I propose a more dense text as follows:
/*
* 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 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
*/
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
2ae2100
to
d6c0398
Compare
@A-Paul done. |
@Josar, thank you for addressing all change requests. CI is happy. ACK and go. |
Debug pin can be used to probe timer interrupts. Thus, determine when an interrupt occurs and how long the ISR takes.
The timer interrupt times can be probed with a oscilloscope if pin
DEBUG_TIMER_PIN
, the respectiveDEBUG_TIMER_PORT
andDDEBUG_TIMER_DDR
are defined in the makefile as follows.