Shop OBEX P1 Docs P2 Docs Learn Events
Reading device-controlled clocked data — Parallax Forums

Reading device-controlled clocked data

upand_at_themupand_at_them Posts: 61
edited 2010-02-02 23:11 in BASIC Stamp
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.

Mike

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-01 22:53
    Yes. There's no Stamp command for this.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-02 02:22
    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.
  • upand_at_themupand_at_them Posts: 61
    edited 2010-02-02 14:08
    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
    NEXT
    
  • Spiral_72Spiral_72 Posts: 791
    edited 2010-02-02 16:14
    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
  • upand_at_themupand_at_them Posts: 61
    edited 2010-02-02 23:11
    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.
Sign In or Register to comment.