Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By clarkegriffinx
#91271 Timer Interrupt Considerations
These routines

need to be extremely fast to execute, and it is often best to simply set a number of flags or states within the Interrupt Service Routine, then evaluate them when required in your normal thread code in loop().
only fire when the configured timer overflows
are restricted to a small number of timers depending on the MCU hardware in use.
can only set values to variables declared with VOLATILE, which ensures they arent optimized away, and can be used reliably in the ISR and in the main loop() code
NOTE - Timer interrupts may interfere with other functionality (PWM for example) depending on the timer chosen to configure.

e.g. ESP8266 gas 2 x Timers available:

0 (Used by WiFi), 1 is available to configure.

e.g. Arduino Uno has 3 x Timers available:

Timer0 - An 8 bit timer used by Arduino functions delay(), millis() and micros().

Timer1 - A 16 bit timer used by the Servo() library

Timer2 - An 8 bit timer used by the Tone() library

The Mega boards have Timers 3,4,5 which may be used instead


hope this helps
User avatar
By lumusislight
#92270
What other variants have you tried? I'm struggling with this task to do my assignment



Hi,

I used a generic ESP8266 + Arduino Core and AsyncWebserver + Wi-fi for a phase angle control.
Have you tried to use an Attiny85? It may be used as a slave interrupt generator. And you could also send your control commands over I2C.
User avatar
By ljglmail
#93208 There are several ways to achieve an interrupt on the ESP8266, but you need to be careful of the timing.

TIMER0 can be set to trigger on Fcpu * 4 when it overflows. So if Fcpu is 8MHz then the interrupt will happen every 0.5ms (4*0.5ms=2ms). But according to the data sheet, any interrupts with a priority higher than level 3 will not work at all (see section 12.2 of the datasheet). This includes any interrupts triggered by TIMER0 as well as IRQ0.

UART_RX has a higher priority than anywww.imybkexperience.com www.mykfc-experience.com www.mybpcreditcard.one
other interrupts and therefore won't work either unless you lower its priority by adding "PRIO1" in front of it in your code.

If you want to use timers without using UART_RX you can use TIMER1 or TIMER3 instead which have a default priority of level 2 (see section 7.6 of the datasheet). You can change their priority by adding "PRIO0" or "PRIO2" in front of them in your code respectively.