ShiftOut. Using PIC as Slave device.


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Something like this should work (untested). Note that is "blocking", and that the code will not advance past this until you get 8 high-to-low transitions on the clock.

    Code:
    GetNextByte:
    
    BitCounter = 0
    GetNextBit:
      While ClockPin=1:Wend                 ; Sits here and does nothing while clock pin is high
        DataByt.0 = DataPin                 ; Samples data pin as soon as clock goes low
        BitCounter = BitCounter + 1         ; Keeps track of number of bits received
        If BitCounter = 8 then goto GotByte ; When we have a byte, get out
        DataByt = DataByt << 1              ; Move things over for next bit
      WHILE ClockPin=0:WEND                 ; Sit here while clock is low
        Goto GetNextBit                     ; Grab next bit if we haven't got all 8
        
    GotByte:
    ...
    ...
    ...
     END
    Charles Linquist

  2. #2
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Thank you for the help and advice, I appreciate it.

    Tony A

Similar Threads

  1. Watchdog Timers
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th August 2014, 18:03
  2. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  3. Smart Star (how to use shift registers)
    By mackrackit in forum Code Examples
    Replies: 3
    Last Post: - 30th November 2008, 20:06
  4. Reading a slave USB with a pic
    By pcaccia in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th October 2008, 12:00
  5. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33

Members who have read this thread : 0

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

Posting Permissions

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