STM32 checking self-written delay function

Hello,
I am writing OneWire communication between STM32 and DS18B20. There should be applied precise delays in us, as I know, HAL guarantee only ms, so at this play timers came into play.

When I started an application, I saw that values on the oscilloscope not fully matched expected delays.

Is there anyway to ckeck if my delays in us countinng properly? I am using 8 MHz BluePill with 8-1 Prescaler.
 
The simplest and most foolproof one-wire setup is using a UART! That guarantees correct timing regardless of MCU clock speed.

Either:
Set the TX output to open collector, connect that and the RX input to the device and a pullup.
Or, connect RX to the bus feed the pullup from the TX pin.

Use 9600 Baud for initialisation, then 115200 for the bit transfers. Those gives appropriate pulse timing.

More info here:

 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…