Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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:

 

Latest threads

New Articles From Microcontroller Tips

Back
Top