smartpin SPI (bidirectional) sample code?
in Propeller 2
Had a bit of a search but didn't find anything obvious, I'm sure someone has some examples of this to avoid re-inventing the wheel?
Comments
Chips booter which accesses the FLASH. He uses separate send and receive routines.
My SD booter which uses a combine send/receive routine with various entry points depending on what you are needing to do. Easiest way, search for the label SENDFF.
Peters TAQOZ. YOu will have to ask Peter.
But bit bashing is useful too
Smart pins are used in the UART side, because highest baud rate helps there, and the buffering buys time to allow SPI bit-bash.
I think one reason to KISS on SPI was to keep the boot silicon minimal, and so lower the risk of smart pin flaws causing dead-in-water outcomes...
Things like SPI and I2C and serial are so slow compared to P2 clock speed, seems very doable...
That speed also outruns my Scope, so no pictures...
Enjoy!
Mike
180Mbaud = 180bps = 18MB/s
We can write to hub at 4Bytes/clock for a block using wrlong and setq (plus setup), so 4B @ say 180MHz = 720MB/s
Well there are some pretty high SPI clock rates out there, 40MHz and up...
Yes, I tried and failed. I have the data in longs in the LUT but failed over days to get my buffers running with long transfers to/from HUB.
Finally I gave up, just transfer Bytes from HUB to LUT and vice versa, shortend everything up and made space to include decimal, hex output and string input into the COG.
I need to check the new printf stuff in spin2gui/fastspin to maybe include that also to be compatible with them existing drivers.
Weekend is coming...
Enjoy!
Mike
final code in TAQOZ thread
***UPDATED***
Here is some TAQOZ smartpin SPI code (only output for now)
input working, tested with MISO looped back with MOSI with a jumper
and MISO looped back internally with MOSI via 'a' input selector relative pin -1 (see commented out code)
( 300MHZ 3.3ns PER CLOCK 10000 = 33.3us ) 8 := CLK 9 := MOSI 10 := MISO 11 := SS 15000 := FREQ CLKHZ FREQ / := N_PULSES : CPOL0_CPHA0 CLK PIN %0000_0_0_0_000_000 8 << %1_00100_0 OR WRPIN N_PULSES 2/ 16 << N_PULSES OR WXPIN L MOSI PIN %0000_0111_000_0000_000_000_000 8 << %01_11100_0 OR WRPIN %101000 WXPIN MISO PIN %0111_1110_000_0000_000_111_111 8 << %01_11101_0 OR WRPIN %100111 WXPIN \ MISO PIN %0000_1110_000_0000_000_111_111 8 << %01_11101_0 OR WRPIN %100111 WXPIN ; : CPOL1_CPHA1 CLK PIN %0000_0_0_1_000_000 8 << %1_00100_0 OR WRPIN N_PULSES 2/ 16 << N_PULSES OR WXPIN L MOSI PIN %0000_1111_000_0000_000_000_000 8 << %01_11100_0 OR WRPIN %101000 WXPIN MISO PIN %0111_0110_000_0000_000_111_111 8 << %01_11101_0 OR WRPIN %100111 WXPIN \ MISO PIN %0000_0110_000_0000_000_111_111 8 << %01_11101_0 OR WRPIN %100111 WXPIN ; : SEND ( TX_BYTE -- RX_BYTE ) SS PIN L MOSI PIN F REV 23 >> WYPIN L MISO PIN L CLK PIN 8 WYPIN WAITPIN MOSI PIN F SS PIN H MISO PIN RDPIN F REV ;
Sample
CPOL1_CPHA1 TAQOZ# $00 SEND .BYTE --- 00 ok TAQOZ# $FF SEND .BYTE --- FF ok TAQOZ# $AA SEND .BYTE --- AA ok TAQOZ# $11 SEND .BYTE --- 11 ok
CPOL0_CPHA0 TAQOZ# $00 SEND .BYTE --- 00 ok TAQOZ# $FF SEND .BYTE --- FF ok TAQOZ# $AA SEND .BYTE --- AA ok TAQOZ# $11 SEND .BYTE --- 11 ok