CMM2 vs. PicoMite 2 Mio For-Next-Benchmark

Author Message

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 182
Posted: 07:41pm 25 Sep 2022      

  phil99 said  As an experiment to see how fast a Pico can read a pin in a FOR - NEXT loop I wrote a program to read a DHT11 temp / humidity sensor and found you can fill an array at 15uS per sample.

CPUSPEED = 378000 kHz, a one digit pin number and all on one line. Every character slows it down.
Here is the relevant part.

'Data format - 80uS high start pulse, 50uS low + 25uS high = 0, 50uS low + 70uS high = 1
Dim integer n
' deliver 20 mS pulse to wake up DHT11
 SetPin 1,dout,oc
 Pulse 1,20
 Pause 19
 SetPin 1,off
 SetPin 1,din 'Get the samples
 For n=0 To 329:a(n)=Pin(1):Next
 SetPin 1, off  'Got the samples
'for max. speed the above 'for-next' must be on one line with fewest characters

Very interesting! So one can sample more than 1/15uS = 66666 samples a seconds using for-next on a pico.