1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

How to implement SPI using low-cost Microchip PIC16C5X series

Discussion in 'Embedded' started by John Tan, Feb 19, 2004.

  1. John Tan

    John Tan Guest

    How can we easily implement SPI using Microchip PIC16C5X series
    devices, using some GPIO. If firmware achievable to implement a
    slave/master interface.

    Thanks for everyones input here....!
    John Tan, Feb 19, 2004
    1. Advertisements

  2. SPI (master) is extremely easy to do in software on any micro - just wiggle the clock line and
    squirt the bits out.
    Mike Harrison, Feb 19, 2004
    1. Advertisements

  3. John Tan

    Leon Heller Guest

    I've implemented software SPI on the AVR '2313, with several slaved to a
    mid-range PIC with hardware SPI as the master. It was quite easy. You
    should be able to do the same with your PIC.

    Leon Heller, Feb 19, 2004
  4. John Tan

    Max Guest

    Should give you the general idea (untested):

    movwf tmp
    movlw 8
    movwf cntr
    btfss tmp,0
    bcf spi_out
    btfsc tmp,0
    bsf spi_out

    bsf spi_clk
    bcf spi_clk

    rrcf tmp
    decfsz cntr
    goto $1



    movlw 8
    movwf cnt
    clrf tmp
    rrcf tmp

    bsf spi_clk
    btfsc spi_in
    bsf tmp,7
    bcf spi_clk

    decfsz cntr
    goto $1

    movfw tmp
    Max, Feb 19, 2004
  5. John Tan

    Rob Young Guest

    Look at some of the C compilers for the PICs. At least one (CCS,
    www.ccsinfo.com) has built in support for SPI master. If the chip as
    SPI hardware you can target the function for that or use just about
    any combination of I/O pins.

    Also look at the Microchip application notes for SPI:


    Rob Young
    Rob Young, Feb 20, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.