On the 18F4550, SDO is PORTC.7, SDI is PORTB.0, and SCK is PORTB.1
In the GCB Help file, under the SPI Overview section, it says:
"#define SPI_HardwareSPI 'comment this out to make into Software SPI but, you may have to change clock lines"
Does this means if I comment out this line, I can change SDI from PORTB.0 to PORTD.7?
Is there any other code I must use to change Ports?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I understand. A number of the SPI device libraries, most of them, support hardware and software implementation for SPI.
If you looking at the Help: SPI Overview then I understand.
The "#define SPI_HardwareSPI' refers to the example code shown.
This example demonstrates the SPI capabilities for the mega328p. The process is similar of any microcontroller..
This example show using the hardware SPI option and a sofware SPI option.
Using hardware SPI mode - make sure the #define SPI_HardwareSPI is not commented out. Using software SPI mode - comment out #define SPI_HardwareSPI. The example code will then use software SPI.
So, for your 18F4550 use the same method shown in the SPI Help example.
define your ports, InitSPIMode (as shown in below and in the Help) and call SendByteviaSPI - SendByteviaSPI will handle the Hardware and Software SPI support for you.
Evan
#define SPI_HardwareSPI 'comment this out to make into Software SPI but, you may have to change clock lines'PinmappingsforSPI-thisSPIdriversupportsHardwareSPI#define SPI_DC portx.n ' Data command line#define SPI_CS portx.n ' Chip select line#define SPI_RESET portx.n ' Reset line#define SPI_DI portx.n ' Data in | MISO#define SPI_DO portx.n ' Data out | MOSI#define SPI_SCK portx.n ' Clock LinedirSPI_DCoutdirSPI_CSoutdirSPI_RESEToutdirSPI_DOOutdirSPI_DIIndirSPI_SCKOutInitSPIMode'SendSPIbytesindependentofhardwareandsoftwareSPIconfigdoforeversetSPI_CSOFF;setSPI_DCOFF;SendByteviaSPI(byte1)setSPI_CSON;setSPI_DCONsetSPI_CSOFF;setSPI_DCOFF;SendByteviaSPI(byte2)setSPI_CSON;setSPI_DCONsetSPI_CSOFF;setSPI_DCOFF;SendByteviaSPI(byte3)setSPI_CSON;setSPI_DCONwait10msloop'**************MEthodssubInitSPIMode#ifdef SPI_HardwareSPISPIMode(MasterFast,SPI_CPOL_0+SPI_CPHA_0)#endifsetSPI_DOOFF;setSPI_CSON;thereforeCPOL=0setSPI_DCON;deselectEndsubsubSendByteviaSPI(inSPISendByteasbyte)setSPI_CSOFFsetSPI_DCOFF;#ifdef SPI_HardwareSPIFastHWSPITransferSPISendBytesetSPI_CSON;exitsub#endif#ifndef SPI_HardwareSPIrepeat8ifSPISendByte.7=ONthensetSPI_DOON;elsesetSPI_DOOFF;endifSETSPI_SCKOn;;thereforeCPOL=0==ON,and,whereCPOL=1==ONrotateSPISendByteleftsetSPI_SCKOff;;thereforeCPOL=0=OFF,and,whereCPOL=1==OFFendrepeatsetSPI_CSON;setSPI_DOOFF;#endifendSub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using an 18F4550 and version 0.98.01.
On the 18F4550, SDO is PORTC.7, SDI is PORTB.0, and SCK is PORTB.1
In the GCB Help file, under the SPI Overview section, it says:
"#define SPI_HardwareSPI 'comment this out to make into Software SPI but, you may have to change clock lines"
Does this means if I comment out this line, I can change SDI from PORTB.0 to PORTD.7?
Is there any other code I must use to change Ports?
What library are you using? The Help is referring to GCB library devices.
By library do you mean hwspi.h which I'm using?
I understand. A number of the SPI device libraries, most of them, support hardware and software implementation for SPI.
If you looking at the Help: SPI Overview then I understand.
The "#define SPI_HardwareSPI' refers to the example code shown.
So, for your 18F4550 use the same method shown in the SPI Help example.
define your ports, InitSPIMode (as shown in below and in the Help) and call SendByteviaSPI - SendByteviaSPI will handle the Hardware and Software SPI support for you.
Evan
Thanks!