View Full Version : Reading device-controlled clocked data
02-02-2010, 05:51 AM
I'm interfacing a Stamp to a device that has clocked data. The device controls both the data line and the clock line. I went through the Stamp manual, but I just wanted to know before I write my own routines....There's no Stamp command for this, right?
The ShiftIn command only works when the Stamp controls the clock. And the SerIn command only works for a known transfer rate (baud), which I think is unknown in my case.
02-02-2010, 06:53 AM
Yes. There's no Stamp command for this.
02-02-2010, 10:22 AM
It would be very easy to do this with a Propeller, mostly because of the speed available. One cog could simply act as a clocked shift register. You could also do this with a Stamp if you use external hardware and there's enough time after a group of clock pulses for the Stamp to grab the data itself. If it's bytes, you could use two 74HC165 serial to parallel shift registers, one to circulate a one bit so the Stamp knows when to grab the data, the other is used to shift in the data which is then latched until the Stamp can read it. The external clock would clock both shift registers and the circulating one bit would latch the data into the latch. The Stamp would need to use 9 I/O pins, 8 for the data and 1 for the one bit that tells it that there's data to read.
02-02-2010, 10:08 PM
Yeah, I wrote a routine last night and I think I ran into the speed limit for the Stamp. I can probably get it working with just a PIC and no external hardware (maybe pullups or pulldowns), but I have the Stamp HomeWork board and it was easy to setup for testing.
This is basically what I wrote:
FOR i = 1 TO 8
DO : LOOP UNTIL CLK = 1
v1.BIT7 = DT
v1 = v1 / 2
DO : LOOP UNTIL CLK = 0
02-03-2010, 12:14 AM
I don't know how much speed you need to make up, but a bit shift should be much faster than a divide by two..... especially on an inside loop:
v1 = v1 / 2
02-03-2010, 07:11 AM
I hooked up the USB O'scope and got clock pulses 120us wide and about 350us between. I think 120us may be pushing it, because it's the top of the pulse that I need to check the data line. Oh well.