Forums

How to implement SPI using low-cost Microchip PIC16C5X series

Started by John Tan February 19, 2004
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....!
On 19 Feb 2004 02:11:45 -0800, bktan1974@netscape.net (John Tan) wrote:

>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....!
SPI (master) is extremely easy to do in software on any micro - just wiggle the clock line and squirt the bits out.

John Tan wrote:

> 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....!
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 -- Leon Heller, G1HSM Email: aqzf13@dsl.pipex.com My low-cost Philips LPC210x ARM development system: http://www.geocities.com/leon_heller/lpc2104.html
On 19 Feb 2004 02:11:45 -0800, John Tan wrote:

>How can we easily implement SPI using Microchip PIC16C5X series >devices, using some GPIO. If firmware achievable to implement a >slave/master interface.
Should give you the general idea (untested): spi_writebyte: movwf tmp movlw 8 movwf cntr $1 btfss tmp,0 bcf spi_out btfsc tmp,0 bsf spi_out bsf spi_clk bcf spi_clk rrcf tmp decfsz cntr goto $1 return ;----------------- spi_readbyte: movlw 8 movwf cnt clrf tmp $1 rrcf tmp bsf spi_clk btfsc spi_in bsf tmp,7 bcf spi_clk decfsz cntr goto $1 movfw tmp return -- Max
bktan1974@netscape.net (John Tan) wrote in message news:<eb4dd21b.0402190211.6ec7d68f@posting.google.com>...
> 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....!
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: http://www.microchip.com/1010/suppdoc/appnote/func/commun/spi/index.htm Rob Young rwyoung@ieee.org