Shiftout sclk Inversion
TomS
Posts: 128
Is there any way to invert the clock polarity with software when using the SHIFTOUT function? A ~ in front of the cpin doesn't work. All it does is invert the pin number.
Thanks
Tom Smuts
Thanks
Tom Smuts
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
I can do the inversion with an external chip but I want to eliminate it.
Tom Smuts
If you're looking for a negative-going clock which IS supported on Motorola microprocessors using SPI, there is no way to do that through the software with the PBASIC Stamp. I suppose you could flip the clock pulse externally, if you chose to do so.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
I'm using SHIFTOUT, not SHIFTIN. You might think is still doesn't matter but it's now dependent of the external device you're writing to. I'm writing to an Analog Devices AD9834 DDS chip and it REQUIRES that the clock be high when the frame sync goes low.
Set the sclk line low before entering the SHIFT routines. Otherwise you may get an extra negative edge clocking that you don't want when the command starts up. I learned that the hard way when I tried to share the clock line between I2C and SPI devices. I2C likes the clock line to rest high, and SPI (in Stamp flavor of it) likes the clock line to rest low. There are extra steps required to manage the clock line to combine the two. I wouldn't recommend it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
It doesn't work. If you force the clk HIGH it is brought low before the first clk pulse. TH AD9835 will take this as an extra clk pulse.
Tom
It looks like you can do:
HIGH Sclk
LOW Sync
HIGH (or LOW) firstdatabit
LOW Sclk ' Clock·out bit 16 -- Optional, this MAY be what the SHIFTOUT does anyway
SHIFTOUT SData, SClk, MSBFirst, [noparse][[/noparse]RestData\15] ' At 16 Khz, clock in bits 15..1
HIGH Sclk
HIGH SData
HIGH Sync
It may take some experimentation to get some pattern that the DAC will accept -- and it may not be possible at all. But at least this gives you a place to start. The idea is to start the pattern with something that keeps the chip happy, then use SHIFTOUT to send the rest of the bits.
In the worst case you can 'bit-bang' the data, but that's pretty slow...
Post Edited (allanlane5) : 2/24/2006 10:48:41 PM GMT
You may be on to something. I'll give it a try. I do see one possible problem. That is if the data is passed through the DDS chip when clk is LOW and isn't edge triggered. If it simply passes through then SHIFTOUT sets up data before the clk goes high and if the preceding bit was different you would get an error. It's easy enough to try though.
· LOW FSync
· SHIFTOUT SData, SClk, MSBFIRST, [noparse][[/noparse]adcValue\16]
· HIGH FSync
For SHIFTOUT the data is put on the output pin and then the clock pin is blipped 0-1-0, so there is a falling edge while the data bit is valid that your device can use.· Am I missing something?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 2/24/2006 11:24:48 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.
So the gyrations above are to implement this, then use the standard SHIFTOUT functionality to shift the rest of the bits. And it should work, since as you say the clock pin is 'blipped' you get both clock edges for follow-on bits.
Thanks
Tom Smuts
Tom Smuts