Using SPI in PIC16f877A


+ Reply to Thread
Results 1 to 3 of 3

Thread: Using SPI in PIC16f877A2089 days old

  1. #1
    Farah
    Guest Farah's Avatar

    0 Not allowed!

    Default Using SPI in PIC16f877A

    Hi,
    My project is simply this: I have 3 buttons connected to a single input channel of the pic, one byte is to be send via SPI to an ethernet interface board ( ENC28J60 + rj45 connector), then the data is to be displayed on the PC to know which button was pressed.

    I tried simulation on ISIS with LEDs as outputs to the microcontroller and it worked. However I need help to how exactly i should modify the code to send (and later receive) data to SPI interface.
    I read the datasheet and it seems SHIN and SHOUT are to be used, but i am not exactly sure how. What are the configuration I have to include in the code?


    new 3.txt

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    528
    Thumbs Up
    Received: 31
    Given: 7
    Total Downloaded
    3.87 GB

    0 Not allowed!

    Default Re: Using SPI in PIC16f877A

    What you need to do depends in if you are intending to use the PICs MSSP module and associate pins for your SPI bus or if you want to use alternative pins for the SPI bus.

    If using the MSSP module SPI can be simply achieved by correctly setting the SSPSAT and SSPCON then you simple write to SSPBUF to transmit data, wait for the BF bit to indicate the receive buffer is full and read SSPBUF to obtain the incoming data although you may need to use the rev command to reverse the data depending on if the data needs to be LSB or MSB first.

    If you want to use any pins on the pic then I believe the SPI example in the PDS/Samples folder my be of some assistance if you have not already looked at it.

    Personally I have only ever used the MSSP module for SPI as in theory it should free the processor for other things while the MSSP module does its stuff unlike the SHin/SHout commands which I believe (although I may be wrong) bit bangs and therefore uses the processor to do its thing, which may or may not be an issue depending on your application.

    I am certain this topic has been covered several times so a search of the forums for SHin & SHout should reveal more advice and examples of how to use it.
    Last edited by Stephen Moss; 9th June 2014 at 09:23.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Farah
    Guest Farah's Avatar

    0 Not allowed!

    Default Re: Using SPI in PIC16f877A

    Thanks for the reply Stephen.
    I actually want to use the PIC MSSP module, since I am connecting the SPI interface with an Ethernet board. So I guess I will do as you suggested and go without the SHin/SHout commands.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. [SOLVED !] Pic16f877a
      By Sourav in forum Absolute Beginners Section
      Replies: 17
      Last Post: 3rd June 2016, 13:50
    2. [SOLVED !] Barcode generation through pic16f877A
      By aqibulfat in forum Projects discussion
      Replies: 5
      Last Post: 5th June 2015, 15:50
    3. [SOLVED !] ADC Maths Trouble on pic16f877a
      By Bull in forum The Lounge
      Replies: 23
      Last Post: 23rd June 2012, 12:59
    4. [SOLVED !] PIC16f877a
      By Richard in forum The Lounge
      Replies: 0
      Last Post: 19th July 2007, 18:29
    5. [SOLVED !] FS: Pic16f877a
      By Richard in forum Wanted and For Sale
      Replies: 0
      Last Post: 29th October 2005, 07:18

    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