Shop OBEX P1 Docs P2 Docs Learn Events
[FYI] single wire high speed serial link (updated 20110514) — Parallax Forums

[FYI] single wire high speed serial link (updated 20110514)

kuronekokuroneko Posts: 3,623
edited 2011-05-13 22:18 in Propeller 1
Inspired by [thread=99222]this thread[/thread] and because I have a thing with counters I came up with a proof of concept driver which receives a long (32bit) in 38 instructions over a single wire (32 for the actual bits including assembly and 6 for maintenance).
  • The receiver requires 2 pins, one for the actual data, another for a counter controlled gate pulse.
  • The result is ready for consumption in PHSB and ATM not stored anywhere else.
  • The transmitter is happy with a single output pin.
How does it work?

Transmitter

Nothing to see here really, the value to be sent is rotated in front of the output bit in OUTA. Data format is 2 start bits (1/0), 32 bits payload and 1 stop bit (0).

Receiver

CTRA runs in 25% duty single-ended mode and delivers the gate pulse (one pulse every 4 cycles). CTRB runs in logic A&B mode (A is the gate pulse and B is the incoming data). The useful side effect is that FRQB is now accumulated into PHSB every 4 cycles if the incoming data bit is 1. However, this also means we have to adjust FRQB every 4 cycles to present the correct bit pattern which is done by simply shifting it down.

The attached source itself contains both subroutines and a simple test which starts one cog and tells it to transfer a given value. Then it starts another cog which receives the value and compares it against an expected value. As I develop on the Hydra, successful transfer will light up game pad 0 (the LED that is).

Update 20101124: I was kind of fed up with the inaccuracy of single pulse sampling so I borrowed some code from the [thread=125046]Countiplier[/thread] and rewrote the link driver. It's now happy with a single pin for the receiver and doesn't suffer from internal chip delays. My demoboard just finished a successful run sending a complete LFSR (2.6 hours @80MHz) over the link. Code is attached.

Update 20110209: Added a more ready-to-use demo archive (proplink). Removed unreliable implementation (still available on request).

Update 20110514: Increased net transfer rate. Also, moved this thread from POC to FYI.

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2009-02-12 06:54
    What I would like to achieve is transmission and reception to be done in the counters without timing dependant code. I belive that it can be sent ok using the video section. I dont want the cog to get "stuck" in a waitpxx instruction. Just on my way out so will check your code on my return. And thanks smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps (SixBladeProp)
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-02-12 14:44
    @kuroneko: I have just studied your code. Looks good. 50nS per bit = 20Mbps.
    Now, must PIN_CxD (clock/4) be made an output to work? I am wonderng if there is an internal connection, or does it have to definately go out onto the pin to work?

    Going to have to work a way to do send and receive in the same cog. Then I only have to get a protocol for more than 2 props - easy to do with delays - just send a couple of bits for an address, etc, a few stop bits for the other end to handle, then spit out the 32 bits. Could be multiple 32 bits with stops in between. No need to resync with tied oscillators.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps (SixBladeProp)
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-02-12 16:15
    Just tried it out - works great smile.gif
    However, as you said it wastes a pin (I tried it just in case there was an internal connection) :-(

    So I guess I have 3 choices
    * Kuroneko's method - fastest 20Mbps and wastes a pin
    * Beau's method - next fastest 10Mbps
    * Baggers' method - FullDuplex at 1.7Mbps?

    The first two are simplex - i.e. they can't send and receive at the same time.

    Maybe I have to use a pair of pins and Baggers method, and if a large block is needed then upgrade on the fly to Kuroneko's for the block and step back down.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps (SixBladeProp)
    · Prop Tools under Development or Completed (Index)
    · Emulators (Micros eg Altair, and Terminals eg VT100) - index
    · Search the Propeller forums (via Google)

    My cruising website is: ·www.bluemagic.biz
  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-02-12 20:05
    My vote is for Baggers' method, invoking Kuroneko's method when high volume bursts are needed.

    The choice between baggers method and Kuroneko's method should be tested using two subroutines.
    The first encapsulates baggers method. The second invokes Kuroneko's method.
    Starting off with baggers method and reaching some inflection point to call Kuroneko's method will simplify testing.
    Then a sliding window can be coded switching between the two methods depending on baudrate.

    Perhaps I will code all three ( including Chips method ), and make the determination myself.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • kuronekokuroneko Posts: 3,623
    edited 2009-02-13 00:10
    Cluso99 said...
    Now, must PIN_CxD (clock/4) be made an output to work? I am wonderng if there is an internal connection, or does it have to definately go out onto the pin to work?
    Unfortunately, as you found out already, it needs a real pin to work. It's a shame we can't use pins from OUTB though.
  • LawsonLawson Posts: 870
    edited 2009-06-03 21:39
    Cluso99 said...
    Just tried it out - works great smile.gif
    However, as you said it wastes a pin (I tried it just in case there was an internal connection) :-(

    So I guess I have 3 choices
    * Kuroneko's method - fastest 20Mbps and wastes a pin
    * Beau's method - next fastest 10Mbps
    * Baggers' method - FullDuplex at 1.7Mbps?

    The first two are simplex - i.e. they can't send and receive at the same time.

    Maybe I have to use a pair of pins and Baggers method, and if a large block is needed then upgrade on the fly to Kuroneko's for the block and step back down.

    Can anyone provide a link to "Baggers' method"? Being able to pump data between a PC and a USB Protoboard at 1Mbps full duplex (1.5Mbps if the USB chip supports it?) would be NICE.

    Marty

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?

    Post Edited (Lawson) : 6/3/2009 9:46:52 PM GMT
  • simonlsimonl Posts: 866
    edited 2009-06-17 09:31
    Did anyone find Baggers' method? I've looked and can't find any reference to it elsewhere...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    “Before you criticize someone, you should walk a mile in their shoes. That way when you criticize them, you are a mile away from them and you have their shoes.” - Jack Handey.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-20 18:39
    Has anyone been able to locate Baggers' method, I could use it for a project?
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-10 11:28
    A word of advise. Single cycle pulse sampling is unsafe (even on the same chip). Depending on which cog and which pin is used you can get everything from 0..2 active unitsa. In plain English, I have a demoboard configuration where a waitpeq sits there forever despite being hammered with a 40MHz wave on the trigger pin (@80MHz). Other setups let me count twice as many pulses as expected.

    This doesn't mean that 20Mbaud receivers are impossible, just a bit more expensive in terms of h/w :)

    a 0 in this context doesn't mean it's not there, it's just too short to be noticed by the active clock edge.
  • BradCBradC Posts: 2,601
    edited 2010-06-10 11:39
    kuroneko said...
    I have a demoboard configuration where a waitpeq sits there forever despite being hammered with a 40MHz wave on the trigger pin (@80MHz). Other setups let me count twice as many pulses as expected.

    So in other words, under some corner cases that should be documented in an errata, it does not do what it says on the tin?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I mean, if I went around sayin' I was an emperor just because some moistened bint had lobbed a scimitar at me they'd put me away!"
  • kuronekokuroneko Posts: 3,623
    edited 2010-06-10 11:42
    BradC said...
    So in other words, under some corner cases that should be documented in an errata, it does not do what it says on the tin?
    Yes, definitely (you got a spare first-born?) :)
  • kuronekokuroneko Posts: 3,623
    edited 2010-11-24 01:45
    An [post=784536]updated 20Mbaud driver[/post] has been released resolving issues with internal chip delays and excessive resource usage.
  • ericballericball Posts: 774
    edited 2010-11-24 10:45
    Cluso99 wrote: »
    What I would like to achieve is transmission and reception to be done in the counters without timing dependant code. I belive that it can be sent ok using the video section.

    The video generator can be used to generate bitstreams between 2Kbps and 128Mbps (assuming you can feed the WAITVID that fast). 1-32 bits per WAITVID - fire & forget. The only problem I can see is it doesn't stop sending bits even if your code doesn't do a WAITVID. So great for streaming, not so good for intermittent data transmission.
  • kuronekokuroneko Posts: 3,623
    edited 2011-05-13 22:18
    The top post received a driver update which increases the net transfer rate.
Sign In or Register to comment.