Pic to pic interrupt ans serial comm


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91

    Default Pic to pic interrupt ans serial comm

    I have two pics I'd like to send a few bytes between at varying times. Pic1 (18f2525 @ 20 mhz) and Pic2 (16f876 @ 4 mhz). Darrel Taylor's instant interrupts in use! Thanks again Darrel.

    My thought is to send a pulse to RB0 INT/INT of the receiving pic to let it know something is coming and after a short pause, ISR will receive the bytes on RB0, 6 bytes max always in the same order, and go back to what it was doing. Both pics would be set up the same way. Poor planning and lack of forward thinking finds RC6 and RC7 on both pics used up already.

    Question #1. can I change the operation of RB0 on the fly within the ISR to receive the bytes and then change back and return from the interrupt?

    Question #2. How should I be generating the pulse for the interrupt trigger? Pulseout or toggle the pin with a pauseus?

    I've read many threads about Pic to Pic comm but my brain keeps circling around this option.

    Question #3. Is this feasible or should I go back and reread those other threads?


    As always thanks for any suggestions.
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    No problem.

    Just use DEBUG, SERIN or SERIN2 inside the (PBP type) INT_INT handler.
    You don't have to "change the operation of RB0" because once it's in the handler it can no longer cause another interrupt.

    The interrupt trigger is very fast (1 instruction cycle minimum) at 4mhz that's 1 us. But it will take about 50 instruction cycles to get to a PBP type handler, more if using PBPL.

    TX side:
    Code:
    HIGH OutPin
    @  nop         ; add nop's if sending pic is 20mhz
    @  nop
    @  nop
    @  nop
    LOW  OutPin
    PAUSEUS  60    ; 60 if receiving PIC is 4mhz, 15 if 20mhz
    SEROUT2  ...
    DT

  3. #3
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ronjodu View Post
    ... Poor planning and lack of forward thinking finds RC6 and RC7 on both pics used up already....
    As always thanks for any suggestions.
    Depending on how many boards you have in hand, it might be faster to just cut the two traces going to C6-7, and run some jumpers. That will allow you to use the h/w usart, giving you a "received" interrupt, rather than a "begin receive" interrupt... this will be most useful if you are working with time sensitive stuff. Then, for your next board run (if it that is a possibility), you won't have to edit the code. The importance of that is even greater when you are updating firmware in old boards--you won't have to have two versions.

  4. #4
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default Thanks

    Thanks for the replies. Will certainly try this out tonight.

    If I ever do another board for this I would combine everything into one pic and this wouldn't be a problem. For now though it's my web enabled relay board and my PGA2320 volume control board I'm Ruth Goldburg'n together for use in my amp. Most functions work well already just need both pics to be on the same page with a few variables.

    It seems I've done more prototyping with this relay board than my Easypic4 and LabX2 combined.

    More questions to follow I'm sure. Thanks again.
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

Similar Threads

  1. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 19:14
  2. PIC serial going to sleep!
    By stma in forum Off Topic
    Replies: 0
    Last Post: - 31st October 2007, 09:17
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 03:21
  4. 16F877, DS18S20 and Serial Comm Problem
    By YellowTang in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2004, 11:36
  5. serial comm from Pic to STAMP
    By d1camero in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th April 2004, 00:58

Members who have read this thread : 1

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