best way to delay microseconds? | Cypress Semiconductor
best way to delay microseconds?
so, I tried using the CyDelayUs() function, but it sucks (always delays something like 6us+whatever you pass the function).
does anyone have a recommendation for delaying from single microseconds up to hundreds of micro seconds? anything longer than hundreds of microseconds does not need to be that precise, but I want something that when I intend 3us delay, that I actually get 3us ±0.5us. also, something that is robust enough to handle a change in core clock speed without needing to be re-coded for the new clock frequency. is there anything like that in a library?
should I just make a loop of nops? if I make a loop of nops, how can I sample what my current cpu speed is, so I can adjust the loop to maintain accuracy?
I'm curious for the CY8CKIT-042 dev board, but I also just bought a CY8CKIT-059 and would like a solution for both.