New Version: Micromite MMBasic Ver 5.05.03


Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2558
Posted: 03:17pm 30 Jul 2020      

hi,
   have just spent a bit of time looking through how microsecond timing is done in the source code for the MX170/470 version of micromite basic.

i noticed a couple of issues in the timing for the 1-wire routines. according to microchip's application note AN126 here:
https://www.maximintegrated.com/en/design/technical-documents/app-notes/1/126.html
the following timings should be used:

write "1" bit: 6uS low, 64uS hi-Z
write "0" bit: 60uS low, 10uS hi-Z
read bit: 6uS low, 9uS hi-Z, 45uS data valid, 10us idle
reset: 480uS low, 70uS hi-Z, READ, 410uS idle

whereas the mmbasic source uses:

write "1" bit: 8uS low, 64uS hi-Z
(6uS vs 8uS, probably not a big issue)
write "0" bit:same as AN126
read bit: 6uS low, 8uS hi-Z, READ, 56uS idle
(we are reading the data 1uS before it becomes valid)
reset: close to AN126, timing of 481//70/411uS


while the timing error in writing a "1" bit is minor, we are operating right on the edge of failure when reading a bit. in order to safely read a bit, we should be reading close to the middle of the 'valid data' interval; that is using timing of:

read bit: 6uS low, 32uS hi-Z, READ, 32uS idle

note that the code in question, ow_readBit() in "Onewire.c", is used by both the generic 1-wire routines as well as the DS18B20/tempr function. i do wonder if this may be why some forum members have seen issues with DS18B20 sensors of dubious parentage.


cheers,
rob   :-)
Edited 2020-07-31 01:19 by robert.rozee