Hi, I have an HC11 counting edges from an external, asynchronous source, into the pulse accumulator (PA in what follows). Pulse rate is 'slow' in relation to processing and program loop cycle.
The count may exceed 255, so I'm using a small ISR on pulse accumulator counter overflow to increment a high order counter byte. I need to count the pulses over a 1 second window, every second, as follows:
LOOP: Collect the accumulated total from the PA register and high count byte, and store. Clear the PA register and high byte. Wait for a second. GOTO LOOP
The PA rollover is the only interrupt involved, everything else is polled, within a single mainline routine. My concern is what happens if there are almost exactly 256n pulses in one second. If this occurs, then I need to be sure that no mainline - ie. non-ISR - instructions can be interposed between the PA register overflowing and the ISR performing the bump of the high byte. If they can, then there is a possibility that my stored count could be stored incorrectly.
I've been through the detailed timing in the venerable 'pink book', but this is one case that seems not to be covered.
Do I need to do anything special to ensure the count is guaranteed right? BTW, real problem not homework (surely the HC11 is long gone from classrooms these days.?).