Hi Rob!
So we *do* have REPEAT/UNTIL, I thought to miss it just today :-D
Thanks for the hint. Earlier today I only found an older version of the documentation which contained just that problematic example: increasing a word variable inside an interrupt, but that example is gone (or shortened) in the current version.
Yes, stopping the interrupt before reading the variable would be a simpe solution, but I wanted to time my pulses as accurate as possible. I can't disable just the timer update interrupt, as another interrupt copies the timer value. The hardware timer keeps running, and so the timer values may become inconsistent for the interrupt-on-change. Ok, I already handled that inconsistency for it can occur very rarely even without stopping the interrupt, but I did not want to stop it. Well, and I did not think of just stopping that very interrupt, I only thought about stopping all interrupts.
As the place where the actual problem was right now is a very unimportant one, I have two very simple solutions:
If the low-byte value is larger than 253, just skip that part of the program this time.
Or, what I did now:
var volatile word check_value
REPEAT
check_value=changing_value
result=changing_vaue-whatever
UNTIL check_value==changing_value
It would be sufficient to only check the high-byte.
Thanks again for answering even my stupid questions ;-)
Greets,
Kiste