how to make a delay on STM32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-03-07 6:01 AM
Hello!
how to make a delay of N clock cycles? (without timers)I realized asm(NOP) is not working- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-03-07 6:40 AM
I would use DWT_CYCCNT to get loops with some semblance of predictability, or to benchmark other constructs.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-03-07 7:23 AM
> I realized asm(NOP) is not working
In what whay it wouldn't work (if properly spelled of course)? JW- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-03-08 6: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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-03-08 6: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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-03-11 6:07 AM
Thank you for reply. I like this thought, but hoped that a solution exists.
