Shop OBEX P1 Docs P2 Docs Learn Events
PSM Bit Bang Timming Help — Parallax Forums

PSM Bit Bang Timming Help

hippyhippy Posts: 1,981
edited 2008-04-07 01:00 in Propeller 1
RxPasmLoop    waitpne   rxPasmPinMask,rxPasmPinMask
              waitpeq   rxPasmPinMask,rxPasmPinMask

              mov       rxPasmTimeout,rxPasmBitTime
              shr       rxPasmTimeout,#1
              add       rxPasmTimeout,rxPasmBitTime
              add       rxPasmTimeout,CNT
              sub       rxPasmTimeout,#K               ' <---- HERE

              mov       rxPasmBitCnt,#8
              
RxPasmGetBit  waitcnt   rxPasmTimeout,rxPasmBitTime
              test      rxPasmPinMask,INA WC
              shr       rxPasmBitSeq,#1
              muxnc     rxPasmBitSeq,#$80
              
              djnz      rxPasmBitCnt,#RxPasmGetBit 





              mov       txPasmTimeout,txPasmBitTime
              add       txPasmTimeout,CNT
              add       rxPasmTimeout,#K               ' <---- HERE
              
TxPasmSendBit shr       txPasmBitSeq,#1 WC
              muxc      OUTA,txPasmPinMask

              waitcnt   txPasmTimeout,TxPasmBitTime

              djnz      txPasmBitCnt,#TxPasmSendBit





These are is a bit-banged serial input and output routines ( idles low, start bit high ) ... How do I determine what the K's should be to get most accurate time from when INA pin goes high to when INA is next sampled and likewise to get the first bit length right in the tramsit.

Comments

  • mirrormirror Posts: 322
    edited 2008-04-06 21:57
    hippy,
    This is the application for which I most often use Gear.

    Looking at the code though, you've got no instructions that would require anything other than 4 clock cycles. So just count up the number of instructions and multiply by 4. (Initial guess would be 28 for the first k, and about 8 for the second k).

    Other than that, I've never heard of PSM, but I did notice that you've got a bit-and-a-half delay on the receiver - which is a good thing to get you to the middle of the bit period.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • hippyhippy Posts: 1,981
    edited 2008-04-07 01:00
    PSM ~= PASM : With the number of typo's there I think I need to clean my keyboard ! Dyslexing 14400 baud as 11400 baud didn't help matters in my code either.

    "Multiply by 4" ... D'oh ! Not multiply by 1, it's CNT++ every cycle, not per instruction.
Sign In or Register to comment.