ADC0831 pulsout vs high/low
Franny
Posts: 127
in BASIC Stamp
Howdy, in the code below there's the line "PULSOUT CLK, 210" and I was just wondering why couldn't this just be a high followed by a low?
' -----[ Subroutines ]----------------------------------------------------- ADC_Data: LOW CLK LOW CS PULSOUT CLK, 210 SHIFTIN DataOutput,CLK,MSBPOST,[adcBits\8] HIGH CS RETURN
Comments
As to whether HIGH/LOW is faster/slower than 420 usec (210 times 2 Usec), don't know that either off the top of my head. Set up your measuring device and try it.
The ADC0831 requires one pulse on the clock line after being activated to do the
voltage conversion.
Maybe this subroutine from StampWorks Experiment # 28 makes more sense.
result is a BYTE variable, which is 8 bits, so I am guessing that the extra bit, that isn't needed anyway, just gets dropped.
In PBASIC, I/O pins can be defined as a PIN variable or a constant (CON).
This Propeller C lesson defines constants for I/O and also shows how to use SHIFTIN in C.
http://learn.parallax.com/propeller-c-simple-protocols/bit-masks-better-code
I am not sure if Jon's (JonnyMac who wrote StampWorks) 9-bit SHIFTIN trick will work correctly in C.
I didn't get any build errors when I tried it.
Extremely useful, Thanks! : ]