Skip to content
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

Enable interrupts #804

Open
Micilera opened this issue Apr 23, 2020 · 1 comment
Open

Enable interrupts #804

Micilera opened this issue Apr 23, 2020 · 1 comment

Comments

@Micilera
Copy link

Sirs,
Argument: Enable Interruputs
Platform: Arduino Due
Version: v4.3.9 and v4.4.0

File: \src\platform\HAL_DUE\HAL_timers.cpp::HAL_timer_start()
I see the following:

TC_Start(tc, channel);

// enable interrupt on RC compare
tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPCS;
tc->TC_CHANNEL[channel].TC_IER = ~TC_IER_CPCS;

// Finally, enable IRQ
NVIC_EnableIRQ(IRQn);

Looking at some other examples and there are many, I see:

// Enable the RC Compare Interrupt...
t.tc->TC_CHANNEL[t.channel].TC_IER = TC_IER_CPCS;
// ... and disable all others.
t.tc->TC_CHANNEL[t.channel].TC_IDR = ~TC_IER_CPCS;

and that seems to me much more reasonable.

Could you please explain how does your solution work and why?
Best Regards,
Micilera

@Micilera
Copy link
Author

Micilera commented May 2, 2020

I'm sorry that you didn't give us an explanation about your previous
approach of enabling interrupts, but I am happy that you made some little
changes at the code in this area. A little step ahead, but very appreciated.
Very good.
Now I see for the Arduino DUE platform in the same method
HAL_timers::HAL_timer_start() at line 131/132:
// Disable timer interrupt
tc->TC_CHANNEL[channel].TC_IDR = TC_IDR_CPCS;
and few lines later, at line 150/151:
// enable interrupt on RC compare
tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPCS;

So, the disable bit (TC_IDR, Interrupt Disable Register) is set, but
also the enable bit is set (TC_IER, Interrupt Enable Register).
Who will win?
So your approach is very interesting and I would kindly ask you if
you can give us some more details as an expert.
Best Regards,
Micilera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant