2013-03-07 06:01 AM
Hello!
how to make a delay of N clock cycles? (without timers)I realized asm(NOP) is not working2013-03-07 06:40 AM
I would use DWT_CYCCNT to get loops with some semblance of predictability, or to benchmark other constructs.
2013-03-07 07:23 AM
> I realized asm(NOP) is not working
In what whay it wouldn't work (if properly spelled of course)? JW2013-03-08 06:16 AM
To clive1:
Asfar as I know, with this method is not accurate in1
cycle
or at least in a fewcycles
.To maclawek.jan:
I mean - it will work, but not as it should. And I have to get a delay inN
clock cycles.Document PM0056, page 103
:
NOP does nothing. NOP is not necessarily a time-consuming NOP. The processor might
remove it from the pipeline before it reaches the execution stage.
Maybe I'm wrong to understand something?
2013-03-08 06:42 AM
To clive1:
As far as I know, with this method is not accurate in1
cycle
or at least in a fewcycles
.Like I said you can use it for benching code sequences that give you specific delays. It's should be good for sub 10 cycle accuracy in a timing loop, so would clearly spank a timer/interrupt implementation. You're simply not going to achieve the granularity you suggest, people who do this professionally use hardware to enforce signal placement. In software you've got flash, cache mechanisms, structural alignment, prefetch, write buffers, memory contention and branch prediction in the way of getting single cycle predictability. I'd wager the spread in flash is closer to 4-5 cycles of potential variability for hard coded instruction sequences. I'd have to go dig for the thread with some specific measurements.
2013-03-11 06:07 AM
Thank you for reply. I like this thought, but hoped that a solution exists.