Has anyone got some suggestions of how to make use of a "third timer" on an ATTiny84? It only comes with an 8bit timer0 and 16 bit timer1, built in, but I could really use a way to trigger an interrupt at a (very approximate) designated interval whilst both timer0 and timer1 are fully occupied with generating PWM outputs from pins.
I don't need a third timer to be anything like as capable as a true timer, all it has to do is trigger an ISR at semi-regular intervals, and it must not interfere with the duty cycle of the outputted PWM signals themselves. A pin change interrupt doesn't interfere with that duty cycle, the PWM generation via timers runs in the hardware independently of whether the code is in the main loop or in an interrupt, but I suspect some hacky ways of getting a third "timer" might be ones which affect PWM duty cycle, hence note here that ways which do that won't be helpful to my situation.
I am clocking the attiny84 with an external 16MHz crystal, and then have both timers in 8 bit mode, where they are running to produce fast PWM at 7.8KHz. But I also need to have an interrupt routine run roughly, every 50us, in which I check various states of other pins. The main loop of code is much slower than this, due to the things it does including floating point maths, so it needs that interrupting every 50us or so. If the once-per 50us interrupt is delayed by up to say 30us that is fine, and if it runs early by even as much as 30us that too is fine, as I said, it is very approximate.
If I could somehow get a trigger for this interrupt at twice the 7.8KHz PWM frequency that too might be adequate. Is there any way, whilst PWM is active, to get an interrupt (it doesn't have to be the same interrupt service routine, I could write two identical ISRs each to be triggered by different conditions) to fire both every time a timer wraps round, and every time it passes the half-way mark?
All my pins are in use, so I cannot have an external circuit generating a 50us period square wave with which to trigger a pin-change interrupt.
I am wondering if the ADC-ready interrupt can be used for this, however I am already making use of two pin's ADC functionality at some points in the code's main loop. I know that wth ADC free running mode, one often gets nonsense corrupt readings for several iterations after switching which pin is being multiplexed to the ADC, so am not sure if this is a viable option.
Thank you
P.S. I am not making any use of delay(), millis() or other library functions which need a timer for them. I've turned off those features in the SpenceKonde ATTiny core compilation settings.
P.P.S. I am still in the planning phase of writing the code I'm discussing, that's why I'm asking this advice before I get started so I'll know which features to use, hence I cannot show any arduino scripts at present.