MKFirmware / MK4duo

MK4duo Firmware Printers 3D for Arduino and Arduino due
http://www.marlinkimbra.it
GNU General Public License v3.0
206 stars 118 forks source link

Enable interrupts #804

Open Micilera opened 4 years ago

Micilera commented 4 years ago

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 commented 4 years ago

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