+ Reply to Thread
Results 1 to 11 of 11

Thread: SPI Communication between a Prop and PIC

  1. #1

    Default SPI Communication between a Prop and PIC

    I am trying to connect a Prop to a PIC MCPU through SPI but have not managed to make it work.

    The PIC cpu is on the Digilent UNO32 board, and the programming environment is around the Arduino framework, where timing for SPI is provided through a clock divider (the main clock is 80 MHz).

    On the prop side, I am using Beau's SPI_Asm object, although have tried the Spin version as well.

    To start, I was trying to get one way communication so I connected the MOSI/CLK lines on the PIC side directly to the pins on the Prop side. The PIC is the master and the prop is the slave, which only really affects which pins connect to which. I have confirmed through a scope that the PIC is putting out a clock and data on the respective pins. Problem is that on the PIC side I do not receive anything, in fact the ShiftIn command never returns.

    To start, what is the easiest way to map the clock divider on the PIC to the clockdelay on the Prop?

    -- Thanks

  2. #2

    Default Re: SPI Communication between a Prop and PIC

    This isn't the answer to your question but I recently bought an UNO32 too and was thinking of doing the same thing. You may want to check out http://www.chameleon-dev.com/ since that has documentation on a PIC24 interfacing to a Propeller using SPI. This may be similar to what you are thinking about. (BTW I also have the Chameleon-PIC which is a great product).

  3. #3

    Default Re: SPI Communication between a Prop and PIC

    I find it useful to use a 74HC595 when getting SPI to work. It uses hardware SPI.
    Leon Heller
    G1HSM

  4. #4

    Default Re: SPI Communication between a Prop and PIC

    @blittled: thanks, I'll take a look and may even look at the Chameleon PIC, the Uno32 is attractive due to price but the software and support is greatly lacking - then again, maybe I have been spoiled by parallax -

    @Leon: part of the attractiveness of the Prop is that by assigning cogs to comm tasks you don't have to add intermediate hardware, so I am trying to avoiding adding a hardware shift register.

  5. #5

    Default Re: SPI Communication between a Prop and PIC

    I use it for testing that the SPI software works. It can then be replaced by the Propeller or PIC. Otherwise you don't really know where the problem is, although a loop-back test can often help.
    Leon Heller
    G1HSM

  6. #6
    Cluso99's Avatar
    Location
    Sydney/Brisbane Australia or 'sailing on the high seas'
    Posts
    9,260

    Default Re: SPI Communication between a Prop and PIC

    Curious by your statement "so I connected the MOSI/CLK lines on the PIC side directly to the pins on the Prop side". You do have MISO connected too don't you???
    My Prop boards: CpuBlade, TriBlade, RamBlade, www.clusos.com
    Prop Tools (Index)
    Emulators (Index) ZiCog (Z80)
    Prop OS (also see Sphinx, PropDos, PropCmd)

  7. #7

    Default Re: SPI Communication between a Prop and PIC

    iirc, Beau's code combined MISO and MOSI on one pin. This is outside my realm of experience. MISO and MOSI are separate lines in my world.
    Last edited by K2; 07-30-2011 at 08:05 AM. Reason: clarity

  8. #8

    Default Re: SPI Communication between a Prop and PIC

    I agree the Arduino compatible libraries need work. I bought the Uno32 to use with Microchip's libraries. I also wanted a PIC based Arduino Clone to use with shields.

    The creator of the Chameleon, Andre LaMothe is currently working on the Scorpion which is a shield with a Propeller with media capabilities http://forums.parallax.com/showthrea...light=scorpion.

    I'm looking forward to this shield. With it you can use the Propeller with any Ardiuno clone.

  9. #9

    Default Re: SPI Communication between a Prop and PIC

    Quote Originally Posted by Cluso99 View Post
    Curious by your statement "so I connected the MOSI/CLK lines on the PIC side directly to the pins on the Prop side". You do have MISO connected too don't you???
    Actually I didn't initially because I was going to try one sided communication; I connected both lines but same result. I am trying to debug the PIC side first, I have successfully used SPI on the Prop to access accelerometers, rate gyros etc., so I know that side works. It is unclear to me if on the PIC side I have to monitor the chip select before issuing the 'transfer' call or if that is done inside the library.

    When I started on this, I never thought it would be some complicated, I guess everything is a lesson ...
    Last edited by ypapelis; 07-30-2011 at 02:28 AM.

  10. #10
    Cluso99's Avatar
    Location
    Sydney/Brisbane Australia or 'sailing on the high seas'
    Posts
    9,260

    Default Re: SPI Communication between a Prop and PIC

    ypapelis: SPI is a two-way protocol, not a one sided communication. Since the pic is the master, is the code you are using on the prop setup for slave use? I haven't looked at the code, so just a suggestion.
    My Prop boards: CpuBlade, TriBlade, RamBlade, www.clusos.com
    Prop Tools (Index)
    Emulators (Index) ZiCog (Z80)
    Prop OS (also see Sphinx, PropDos, PropCmd)

  11. #11

    Default Re: SPI Communication between a Prop and PIC

    Quote Originally Posted by Cluso99 View Post
    ypapelis: SPI is a two-way protocol, not a one sided communication. Since the pic is the master, is the code you are using on the prop setup for slave use? I haven't looked at the code, so just a suggestion.
    Cluso99: I was trying to use Beau's code (in SPIN and ASM) but after going through both of the versions I realized that neither would work because the code is designed under the assumption that the sender is the Master and thus owns the clock line. I need a 'slave' implementation, where the slave waits on the SS line and then data transfers simultaneously on both sides, but the master maintains control of the clock. So effectively, if the master wants to receive data, it has to send something at the same time.

    In retrospect, my initial question was a bit naive; I had never looked into the details and assumed that SPI is a buffered protocol, and didn't realize that I also need to develop a high level protocol to logically synchronize the master and slave.

    I ended up developing my own 'slave-side' SPI implementation in assembly; it works fine for my application and I can define my own high level protocol between the master and the slave to support transfers that are longer than 8 bits and thus have higher bandwidth. The PIC always initiates a transfer (sending a command) and depending on the command it then pauses (to allow the Prop to do what was asked) and then initiates another transfer whose length is the expected length answer. All of this while the master (PIC) maintains control of SS, CLK, and MOSI and the prop maintains control of MISO. Now I am running in trouble on the PIC side, but that's a whole other story.

    Thanks to everyone for the pointers and comments, it may not be apparent but all were helpful.

+ Reply to Thread

Similar Threads

  1. [solved] Prop To Prop Signaling, Not Serial Communication
    By idbruce in forum Propeller 1 Multicore Microcontroller
    Replies: 53
    Last Post: 05-27-2011, 10:31 PM
  2. Propeller DEMO : (14.5 Meg Baud) High Speed Prop-to-Prop Serial Communication
    By Beau Schwabe (Parallax) in forum Propeller 1 Multicore Microcontroller
    Replies: 50
    Last Post: 12-25-2010, 07:29 PM
  3. PASM Coding Challenge - 4 wire Prop to Prop communication.
    By heater in forum Propeller 1 Multicore Microcontroller
    Replies: 34
    Last Post: 12-16-2009, 09:00 PM
  4. Cheap Wireless Prop-Prop Communication
    By Philldapill in forum Propeller 1 Multicore Microcontroller
    Replies: 6
    Last Post: 03-16-2009, 08:38 PM
  5. Prop-to-prop serial communication, what distances?
    By nohab in forum Propeller 1 Multicore Microcontroller
    Replies: 23
    Last Post: 11-16-2008, 02:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts