View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
Sanity check SPI pins |
Posted: Wed May 12, 2010 8:19 am |
|
|
Hi, the following:
#use spi(DO=PIN_C5,CLK=PIN_C3,BITS=16,ENABLE=PIN_B4,FORCE_HW)
gives an "Wrong pins for H/W" error in compiler version 4.107
The device is a 18F2520
Datasheet says
RC5/SDO
RC3/SCK/SCL
can someone please show me the error of my ways! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 12, 2010 11:11 am |
|
|
To use the hardware module, it wants you to specify all the pins.
Add the declaration for the 'DI' pin, and it will compile. An easier
way to do it is, instead of specifying all the hardware pins, just
put in 'SPI1'. Then it knows to use the first hardware SPI module. |
|
![](templates/subSilver/images/spacer.gif) |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Wed May 12, 2010 11:31 am |
|
|
Interesting. I actually want to use the DI pin as an output. Don't need an input for my SPI application.
Does the hardware SPI force you to TRIS your DI pin as an input?
Datasheet states SDI is "automatically controlled by the SPI module"...so I assume hardware SPI is out for me! However it also states "Any serial port function that is not desired may be overridden by programming the corresponding data direction (TRIS) register to the opposite value.
n.b. I actually ended up bit-bashing in software to get me up and running but this will be for future reference! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 12, 2010 2:10 pm |
|
|
Quote: |
However it also states "Any serial port function that is not desired may be
overridden by programming the corresponding data direction (TRIS)
register to the opposite value.
|
Set it up for SPI1, then do a test. Use output_low() and output_high() on
the SDI pin. See if it all works (both the SPI module and the i/o pin). |
|
![](templates/subSilver/images/spacer.gif) |
|