SPI, SCK Pin set up


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: SPI, SCK Pin set up

    I was doing some more reading on the shiftin/shiftout on the forum and it looks like that replaces the hardware pins and you can’t use them together. Since I don’t need interrupts, it looks like this might be easier and I don’t have to configure as much.
    Any words of advice are appreciated.
    Thank you,
    Hylan

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: SPI, SCK Pin set up

    Hi,
    The datasheet have quite a bit of information on the MSSP module, have a look there.

    If you're going to use SHIFTIN/SHIFTOUT you don't need any of the code for MSSP module. The "settings" you talk about depends on the slave device you're going to communicate with. The CKP, SMP & CKE bits controls how the MSSP module operates, much like the MODE parameter for the SHIFTIN/SHIFTOUT command does, there's info in the datasheet for the PIC and there should be info in the datasheet for your slave device as to which mode it uses - the PIC needs to be setup to match the slave device or the data may being sent/received may be misinterpreted at either end.

    By the way, the actual lines you posted just creates aliases to individual bits in the registers so you can write CKE=1 instead of SSPSTAT.6=1 etc. If you look at the SSPSTAT register in the datasheet you'll see that bit 6 is called CKE and you'll also see what it does when either set or reset.

    With the MSSP module you MUST use the designated pins (RC3,4,5 in this case). With SHIFTOUT you can use (almost) any pins you wish since it is a bit-banged firmware routine and doesn't use the hardware peripheral provided by the PIC. SHIFTOUT might be easier to get going but it's kind of slow, the MSSP module can run spit out the bits ~20 times faster... You can definitely use the MSSP module and SHIFTOUT in the same program, just not on the SAME pins - at the same time....but again, MSSP module only on RC3-5, SHIFTOUT on "any" pin since it doesn't USE the MSSP-module.

    /Henrik.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts