|
|
View previous topic :: View next topic |
Author |
Message |
beaker404
Joined: 24 Jul 2012 Posts: 163
|
Remapping SS line for SPI |
Posted: Thu Apr 29, 2021 12:48 pm |
|
|
PIC18F23K22
CCS 5.094
MPLAB 8.92
Setting up an SPI communication on SPI1 between two 18F23K22 controllers.
Like the dummy I am sometimes, I did not set up a Slave Select line between the PICs. Setting one up now as I believe it is the way to go for SPI robustness.
Anyway, the SS1 pin (pin 7 PIN-A5) is being used for other features on the SLAVE side and I was looking at remapping the SS function to another pin (specifically PIN_C2) I am using another pin on the MASTER side as well but controlling it with OUTPUT_HIGH() and OUTPUT_LOW() commands accordingly.
Messing with the SETUP_SPI call gets me errors from the compiler:
Code: | #PIN SELECT SS1 = PIN_C2
#use_spi(slave, mode=0, baud=1000000, stream=STREAM_SPI1, bits=8, ENABLE = PIN_C2, FORCE_HW) |
Now doing the following line only compiles but it will set SS to the default PIN_A5 location.
Code: | #use spi(slave, mode=0, baud=1000000, stream=STREAM_SPI1, bits=8, ENABLE = PIN_A5, FORCE_HW) |
Looking for a bit of insight here, is the SS pin remappable on this processor?
Also if another avenue like SETUP_SPI() is a better way to go, let me know and I will pursue that. Thank you for your insight. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Thu Apr 29, 2021 1:15 pm |
|
|
Unless I am missing something I see no reference to pin remapping in the data sheet so I don't think there any Pin Select re-mappable pins. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Thu Apr 29, 2021 1:56 pm |
|
|
As I suspected. Was hoping there was a loophole I was missing.
I will cut the trace and move the function on the SS pin so I can connect SS function to it. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Fri Apr 30, 2021 1:24 am |
|
|
One thing though, remember there is SPI2. SS2 is on RB0. Possibly this
might allow you to move to pins that work for you (though obviously you
then have to use the secondary SPI data/clock pins.
Other thought, the PIC18F27K40, is pin compatible for your existing chip,
and does have PPS on this pin. Obviously means you will have to add
PPS setup lines for all the other pins as well (the UART etc., are all PPS
on this chip). Gives you a lot more RAM, ROM and EEPROM too.
So with this, no board changes needed, and potentially a better solution.
Price is almost identical. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Fri Apr 30, 2021 6:04 am |
|
|
Ttelmah wrote: | Other thought, the PIC18F27K40, is pin compatible for your existing chip,
and does have PPS on this pin. Obviously means you will have to add
PPS setup lines for all the other pins as well (the UART etc., are all PPS
on this chip). Gives you a lot more RAM, ROM and EEPROM too.
So with this, no board changes needed, and potentially a better solution.
Price is almost identical. |
One caution about PPS: not all peripherals are remappable to all pins. Consult the data sheet. Some peripherals for example are able to be remapped between ports A and B but not C. Stuff like that. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Fri Apr 30, 2021 6:58 am |
|
|
Yes, on a lot of the 'earlier' PPS chips this is the case. However for this
situation there are alternatives. So for the SPI, SPI1 can have it's inputs
mapped to ports A or C, but SPI2 can have these mapped to B or C, so by
selecting between the SPI ports you can use all the ports. |
|
|
|
|
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
|