Shop OBEX P1 Docs P2 Docs Learn Events
Tachyon - How Do I Define SPI Pins? — Parallax Forums

Tachyon - How Do I Define SPI Pins?

JonnyMacJonnyMac Posts: 8,941
edited 2018-02-24 08:52 in Propeller 1
I'm using one of my old Propeller Platform boards with a custom shield that has a 74x165 shift register and a couple of quadrature encoders (was in my October 2010 column). Since the EEPROM is a 24LC512 instead of a 24FC512 I cannot load EXTEND.FTH into it (it hangs). I have an FC part on the way but still want to work with this board.

There are words for SPI in the dictionary, but I cannot figure out how to tell them which pins I'm using for SCLK and MISO.

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-02-24 14:08
    That link is a good start but I suppose I could cover that section a little better in the intro page. However you can define all 4 pins as single long using the & prefix to indicate an IP style notation where each byte is represented in decimal separated by a decimal point. So to pass a chip enable of 23, an MISO (from the chip) of 25, a MISO (from the Prop) of 26 and the clock on pin 24 for instance would be represented as &23.25.26.24. Then use this like this to set the pins: &23.25.26.24 SPIPINS
    You could use pure hex notation $17191A18 SPIPINS but that is hard to figure out and read. The decimal points in the & style number aren't optional as they are responsible for delineating each decimal byte.

    In the V4v7 folder there are several files that access SPI but a nice easy one is FLASH.FTH for serial Flash chips. Some other files are EASYNET and SNIFFER which uses an nRF24L01+ chip for sniffing 2.4GHz. In fact there is a really simple one called BARLEDS.FTH which shows different ways of clocking 64-bits of data to 74HC164 shift registers that only have clock and data:
    There is no chip enable but MOSI is specified as a dummy chip enable.
    &13.00.13.12 SPIPINS
    

    and this is the general bit of code that sends out data:
    pub LEDS ( buf -- )	FROM 0 8 FOR IC@ SPIWRB NEXT DROP ;
    
    although you can send 16 or 32-bits in one hit. It takes 8us to send all 32-bits.
Sign In or Register to comment.