Synchronous Comms between Pics


Closed Thread
Results 1 to 2 of 2
  1. #1
    AndyP's Avatar
    AndyP Guest

    Default Synchronous Comms between Pics

    Hi.

    I am trying to establish a mini data network where there is one master PIC that sends commands to other slave Pics in my latest project, and I wanted to use asnyc comms to achieve this, mainly because of speed. The slave pics will be doing things like software PWM, but a small gap in the pulsetrain won't matter. (Its actually for an RC servo).

    I don't seem to be able to achieve this with SHIFTIN and SHIFTOUT because SHIFTIN still acts in master mode whereby it provides the clock source. How have people achieved this in the past? Is it a case of "rolling your own" input routine?

    Thanks,

    Andy P.

  2. #2
    AndyP's Avatar
    AndyP Guest


    Did you find this post helpful? Yes | No

    Default

    Finally found out that you do need to roll your own. Using bits of code that I found on here and on the old email archive, I come up with this for transmitting one byte:

    TXBYTE:
    FOR COUNTER = 0 TO 7
    DAT_SCU = TMPBYTE.7
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    CLK_SCU = 1 ' Make clock go high after 8 instructions.( = 32 x 125ns = 4us wait)
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    CLK_SCU = 0
    TMPBYTE = TMPBYTE << 1
    NEXT COUNTER
    RETURN

    And for receiving it:

    RXBYTE:
    FOR Counter = 0 TO 7
    WHILE CLK = 0 : WEND 'Wait for clock to go high
    TMPBYTE.0 = DAT 'Assign bit value on datapin to byte variable
    IF Counter < 7 Then TMPBYTE = TMPBYTE << 1
    WHILE CLK = 1 : WEND 'Wait for clock to go low before re-entering loop
    NEXT
    RETURN

Similar Threads

  1. Communicating between two PICs over DC bus
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th May 2009, 12:57
  2. Retrieving infos from multiple PICs on a bus/chain
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th October 2007, 04:42
  3. Synchronous Comms
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 22nd August 2007, 15:21
  4. Programming Pins of PICs?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th August 2007, 18:59
  5. 256 Pics Communicate to 1 Master Pic
    By mazlan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th July 2004, 13:11

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