2
\$\begingroup\$

I have one pressure sensor which I want to interface to microcontroller PIC24FJ16GA to measure pressure.

I don't know which pin of controller to interface a sensor.

I am already using SPI1 in my project in that configuration controller is worked as a slave.

How to interface using SPI2?

I am little bit confusing when read a datasheet of controller.

If some demo code is available then is better understanding for me.

\$\endgroup\$
3
\$\begingroup\$

Both SPI connections are handled the same way. Everywhere it has "x" in the datasheet, e.g. SPIxCON1, simply use a "2" to handle the second interface whenever you would use a "1" to handle the first.

\$\endgroup\$
  • \$\begingroup\$ But I am using SPI1 to slave mode and I want to use SPI2 to master mode.One more question is same controller pin is used for both communication???? \$\endgroup\$ – shail korat Oct 29 '13 at 6:18
  • \$\begingroup\$ @shailkorat: RPIN20 through RPIN23 control SPI input pins, and RPORxx control SPI output pins. Assuming you haven't decided to use too many for other features, you should have enough for both SPI ports. 5 input pins are available, and SPI slave needs 3 inputs, SPI master needs 1. This leaves 12 or 22 (depending on the package) pins for the 4 outputs. \$\endgroup\$ – Ignacio Vazquez-Abrams Oct 29 '13 at 6:30
  • \$\begingroup\$ Thank you for answer my question.I have one question is I have already written code like RPINR20bits.SCK1R=12 RPINR20bits.SDI1R=11 RPINR21bits.SS1R=13 RPOR5bits.RP10R=7 how this value come from I don't understand properly.what is the meaning of this value?? \$\endgroup\$ – shail korat Oct 29 '13 at 6:58
  • \$\begingroup\$ Don't ask questions in comments. Post new questions please. \$\endgroup\$ – Adam Lawrence Oct 29 '13 at 15:26

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.