gfoot wrote:
AndersNielsen wrote:
Edit3: This actually seems to work. My debug pin tells me it's sampling SR right before the 10th rising edge. (Which is later than what I would expect with PB6 count being set to 9 and not 10)
So for example in this 50Hz video system, using timer 1 in free running mode I need to set the latches to 19998 rather than 20000 to wait a whole frame.
But looking at the datasheet this isn't meant to be the case for pulse-counting mode - the diagram clearly shows IRQB falling when the count reaches zero.
I'd still expect it to be delayed based on the system clock, but presumably the keyboard clock rate is much slower, so the system clock delay (and IRQ processing time) shouldn't be significant.
Note that if your IRQ handler is busy when the next interrupt arrives then it will respond to it late.
I also have a feeling PB6 isn’t edge triggered when enabling it - it seems to count once if PB6 is low when pulse counting mode is enabled instead of waiting for an edge. So PB6 should be “normally high” or add a count when enabling.
Still have to confirm.
These two things help a bit with my sanity as it explains why I could only get the correct counts by fiddling with re-enabling PC-mode.
Currently trying to read all 11 bits in two IRQ’s as getting rid of the start/stop bits isn’t helpful.