PDA

View Full Version : Hardware SPI ?



Dick Ivers
- 1st October 2013, 13:23
I noticed that some of the PIC chips I use are equipped with what appears to be hardware SPI. This is part of the MSSP module on 12F1822, 16F1823 etc. Yet there doesn't seem to be any hardware SPI commands in PBP3. Are we missing something here (speed, functionality)?

HenrikOlsson
- 1st October 2013, 16:45
Hi,
You're correct, there are no PBP commands for the MSSP-module, neither in SPI mode or I2C.
However, it's actually quite easy to use "manually", at least for SPI (I've never used I2C so I can't say). There are example programs for both master and slave mode available in the Examples folder of your PBP3 installation.

/Henrik.

longpole001
- 27th October 2013, 01:27
Hi henrik ,

I have the option of using the hardware spi for the cpu driving 2 x spi bused devices ( SD Card , RF module) with individual select pins for each.

to date i have found the shiftout/ shiftin arrangements have worked well for the RF spi device and i have the code
but not tried its with 2 or more SPI , so far or used the registers for the spi HARDWARE.

i am wondering is there any advantage for multi SPI devices to use the hardware SPI than just use the software SPI in this case , and getting it to work using the hardware SPI

Cheers

Sheldon

HenrikOlsson
- 27th October 2013, 06:42
Hi,
The obvious benefit is speed. The hardware SPI is (or can be) SO much faster than using the bit-banged routines. Then of course you can run it interrupt driven so it does its thing in the background instead "blocking" the processor. Then again, it's so fast that there might not be any benefit in using interrupts. It all depends on the amount of data to process etc etc...

Using SHIFTIN/SHIFTOUT you can still have both devices on the same clock and data pins and run separate CS lines to each, just as you would with the hardware SPI, no special need to use a separate set of pins.

/Henrik.