|
|
View previous topic :: View next topic |
Author |
Message |
mew1986
Joined: 15 Oct 2011 Posts: 7 Location: CHENNAI
|
#use spi |
Posted: Fri Nov 25, 2011 12:05 am |
|
|
I am using pic18f4431 for my application.
In that ic I have 2 spi pins.
One is RD1-SDO, RD2-SDI, RD3-SCK.
Another is RC7-DO, RC4-SDI, RC5-SCK.
I want to use #use spi command. In that command
FORCE_HW one command is there........
What my is doubt, is how can I specify the RD1, RD2, RD3 for spi ?
Anyone clear my doubt. _________________ EDWARD |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Fri Nov 25, 2011 3:02 am |
|
|
Two different processes, for different chips.
A lot of later chips, have pins 're-mappable' in software. On these you use #PIN SELECT. However on yours, if you check the data sheet, the re-mapping is controlled by a fuse. If you look at the fuse list for your chip, you have:
3.10 SSP_RD SCK/SCL=RD3, SDA/SDI=RD2, SDO=RD1
3.10 SSP_RC SCK/SCL=RC5, SDA/SDI=RC4, SDO=RC7
So all you do, is select the fuse you require SSP_RD to put the SSP on port D, or SSP_RC to put it on port C.
So just add SSP_RD to your fuses, and in the #use SPI, use 'SPI1', which will automatically select the hardware pins.
You may (according to the age of your compiler), find it does not correctly set the TRIS bits when you use the alternate pins (this varies from chip to chip, and compiler version to version....). If it doesn't work, manually set the TRIS bits as shown in the data sheet.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|