I've an interesting problem:
I'm using an ATMEGA128 to control single wire protocol of ws2812b led stripes.
It uses a simple pulse length protocol which perfectly fits into 20 assembler cycles @ 16MHz.
I've two routines to program the leds:
1. A RAM based buffer is sent to the stripe with an inline assembler routine: Works perfectly!
2. A program flash based buffer is sent to the stripe with lpm Rxx, Z+ has timing jitter problems!?
I calculated the assembler routine to fit into 20 cycles, assuming that lpm takes 3 cycles constantly. Sometimes the sent patterns are having a disturbed timing!?
Copying the data from flash into RAM and sending it via the RAM-routine works also perfectly.
Conclusion: For my surprise, the timing of the lpm instruction does seem not to be constant (three cycles)...sometimes it changes...
This is very bad for the timing of sending data directly from flash...I've to copy it to RAM and send it from there, which unfortunately costs time which I'd like to save!?
Is it really true, that the read of the program flash has not a RISC style constant timing???
...I've some doubts about this explanation of my problem...but it is the only one I see in the moment!
Any other idea to explain the strange behavior is very welcome.