1
\$\begingroup\$

I'm trying to get 3 PIC18F4321s to communicate using SPI, with one of them in master mode and the other 2 setup as slaves. We first got it working with just 2 devices and no SS (slave select) signal with no issues.

We then added the second device and enabled SS and physically switched the SS wires between 5V and GND and it worked as expected, but when we had the master alternate two output pins between 5V and GND and hooked each up to one of the slaves SS pins, the communication stopped working. We hooked the SS lines up to a scope and could see they were switching the way we expected them to and we had significant delays in to make sure they were never enabled at the same time and that there was time between SS going low and SSPBUF getting loaded with the data.

There doesn't seem to be a difference between physically switching the wires and having the uC do it if there are delays, so the only thing we could think of was that the master couldn't drive enough current to the slaves, but I would think that the SS pins are a pretty high impedance, so I am not sure what could be wrong. Any suggestions would be greatly appreciated.

\$\endgroup\$
  • \$\begingroup\$ Post some code. Most-often this type of problem is due to the SS pins not being configured properly. The master SS pins should be set as output push-pull (or open collector with a pull-up), and the slave SS pins as input. The master uC should be able to easily drive the slave inputs. \$\endgroup\$ – Chris Knudsen Apr 19 '17 at 20:46
0
\$\begingroup\$

We ended up solving it by putting all the slave selects through an inverting buffer and making the master select the slaves with a high active signal instead and everything worked. Really not sure why it wouldn't have worked before unless the board wasn't able to drive the pins.

\$\endgroup\$
  • \$\begingroup\$ I'd recommend that you figure out why this is the case before requiring your end-user to rely on the end product. It will come back to haunt you. The solution you have implemented should not be necessary, and may be marginally stable (results may change with temperature, humidity, speed, age, ...). Good luck! \$\endgroup\$ – Chris Knudsen Apr 20 '17 at 12:42
  • \$\begingroup\$ @ChrisKnudsen Thanks for the help. I would definitely look into this more if there were an end user but I'm a student and this is just a lab for a class. Though I will be using the same PIC to collect data from some SPI sensors for a final project, so I will have to get the slave select working properly then. \$\endgroup\$ – C. Spencer Apr 20 '17 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.