Shop OBEX P1 Docs P2 Docs Learn Events
5MB/s Propeller to Propeller Data Transfer with 9 Bits — Parallax Forums

5MB/s Propeller to Propeller Data Transfer with 9 Bits

jazzedjazzed Posts: 11,803
edited 2009-09-16 17:49 in Propeller 1
dat
'{
'-----------------------------------------------------------------------------------
' 5MB/s Propeller to Propeller parallel bus transfer is possible using bits P[noparse][[/noparse]0:8]
' This requires $1xx on P[noparse][[/noparse]0:8] for continuing transfer and $0 to stop.
' A pull-up is used on P8 to control the transfer (pullup because rdbyte 0-extends).
' Use djnz and comparisons to do pointer decrement.

' These are code fragments illustrating the principle and will not compile as is. 

'-----------------------------------------------------------------------------------
' Read Propeller/COG
'
readprop       org      0
                                        ' all bits start as input
  mov          t0,      #0              ' make sure all bits are clear
  mov          ptr,     addr            ' set the base address
  add          ptr,     len             ' add the length
  
:read
  movs         t0,      ina wz          ' looking for 0 on all bits and P[noparse][[/noparse]0:8]
  wrbyte       t0,      ptr             ' write to ptr = address + length
  if_nz djnz   ptr,     #:read          ' if t0 <> 0, continue with ptr-1; else stop 

'-----------------------------------------------------------------------------------
' Write Propeller/COG using djnz pointer
'
writeprop      org      0
  or           dira,    #$ff            ' P[noparse][[/noparse]0:7] are outputs, P8 starts as input

  mov          ptr,     addr            ' set the base address
  add          ptr,     len             ' add the length
  andn         dira,    #$100           ' start write ... bit 9 is pulled high externally
  
:write
  rdbyte       outa,    ptr             ' get byte from djnz controlled pointer
  cmp          ptr,     addr wz         ' test for end condition
  if_nz djnz   ptr,     #:write         ' if ptr > addr, decrement pointer and repeat

  andn         outa,    #$1ff           ' clear bits
  or           dira,    #$100           ' signal finished with bits[noparse][[/noparse]0:8] == 0

'-----------------------------------------------------------------------------------
' Write Propeller/COG using more familiar pointer decrement, djnz len method
'
write2prop     org      0
  or           dira,    #$ff            ' P[noparse][[/noparse]0:7] are outputs, P8 starts as input
  
  mov          ptr,     addr            ' set the base address
  add          ptr,     len             ' add the length
  andn         dira,    #$100           ' start write ... bit 9 is pulled high externally
  
:write
  rdbyte       outa,    ptr             ' get byte from djnz controlled pointer
  sub          ptr,     #1
  djnz         len,     #:write         ' jmp if dec len > 0
  
  andn         outa,    #$1ff           ' clear bits
  or           dira,    #$100           ' signal finished with bits[noparse][[/noparse]0:8] == 0

'-----------------------------------------------------------------------------------
'}




I considered a similar idea using PHSA, but found using PHSA as a pointer to be impractical.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve

Propeller Tools

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2009-09-16 14:52
    Very nice Steve!

    I was thinking of something similar, but was considering 10 pins (separate REQ/GRANT).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
    Morpheus & Mem+dual Prop SBC w/ 512KB kit $119.95, 2MB memory IO board kit $89.95, both kits $189.95
    www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
    Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
  • jazzedjazzed Posts: 11,803
    edited 2009-09-16 17:43
    Actually this is part of an 11 pin scheme for me. P8 is just a repeat while high bit. I'm using a single Host (master) with separate request (ATN) and grant (ACK) ... the ACK will double as an "interrupt" for Device -> Host message notifications. If I have patience for it I'll look into bus mastering, but I don't think that will be necessary.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve

    Propeller Tools
  • Ken PetersonKen Peterson Posts: 806
    edited 2009-09-16 17:49
    I was thinking of a scheme a while back that would use the cog timers to PWM the data on the lines rather than clocking it bit by bit. It wouldn't be as efficient use of bandwidth, but it would allow fewer instructions per bit making the code more efficient. I did some calculations to try to figure out how many bits at a time would be fastest overall, but for the life of me I can't remember what I did with them. confused.gif
Sign In or Register to comment.