I tried to test utime and pyb.udelay by observing But i found that delay is not generated as per the value given.
Below is my testing program for generating delay of 1,10,100 us using pyb.udelay funaction and utime module.
Results for the above program:import pyb
from pyb import Pin
import utime as time
x = pyb.Pin('PD5',Pin.OUT)
y= pyb.Pin('PD6',Pin.OUT)
while True:
x.value(1)
pyb.udelay(1)
x.value(0)
pyb.udelay(1)
while True:
y.value(1)
time.sleep_us(1)
y.value(0)
time.sleep_us(1)
pyb
1us = 30us
10 us = 40us
100us = 130us
utime
1us = 27us
10 us = 36us
100us = 127us
So i wanted to know, why my 1us delay is giving me 27-30us delay. Is it because of the transition from high to low ? Or few microseconds for execution of instructions gets added into the O/P delay. Is their any other way to generate more precise us delays. If yes, kindly guide me through it.