Welcome to the Parallax Discussion Forums, register to participate.
Ctr_Shift = 0000000001 ; use shifter also as bit counter
WAIT_For_Clock_Edge ; Sync to external clock
CY = SPI_DI_Pin ; receive mode
RLC Ctr_Shift ; Shift and count
JC LOOP ; The preloaded 1 Bit appears in CY, when Required bits 1..32 are done.
but the Prop needs a pair of WAITPEQ WAITPNE, so min is 5 lines, 2 waits ~ 3MHz
( say <= 3.20MHz with a 1 clk wait adder ~ 4% clock margin )
1 0 PinA is Stable high
0 1 PinA is Stable Low
0 0 PinA has =\_
1 1 PinA has _/=
and the WAITxx mask, is 2 bits wide, and applies to BOTH PinA and PinB
Wait is now a true edge wait, so even if applied when HI or LO, it will wait for the edge, and only
one wait is needed per loop to sync to an external clock
Min is 4 lines, 1 waits ~ 4MHz ( < 4.444'MHz)
( say <= 4.21MHz with a 1 clk wait adder ~ 5% clock margin )
blittled wrote: »
I'm trying to interface to an Arduino board via SPI and it's minimum speed is 1 MHz.
IO_Data = TxData
BitCtr = 32
WAIT_For_Clock_Rise ; Sync to external clock
CY = SPI_DI_Pin ; Capture data receive mode
RLC IO_Data ; Shift In RX,and out TX
WAIT_For_Clock_Fall ; Sync to external clock
SPI_DO_Pin = CY ; Send Data on opposite edge
DJNZ BitCtr,LOOP ; Count Bits in-out
blittled wrote: »
jmg Thank you again! I thought the divider for the Arduino SPI was only up to 16 and as you pointed out it goes to 128! I'm actually using a UNO32 which has a 80 MHz clock rather than a 16MHz and I was afraid of it being too fast for the 100 KHz slave I'm using. It turns out it has the same SPI frequencies as an Arduino and I believe 125KHz will be close enough since I want to use a known Propeller driver as a base so I know that any commuication problems are with the UNO32. After that I'll try speeding it up using your ideas. Thanks.