Pic to Pic communication


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Hi fignewt,

    a few thoughts you may try...

    Since RC2 could be used as Analog, its important to set it as digital ( like Joe just told you ).
    The Debug/Debugin DEFINES should place the pin output/input, but is never too much to declare it anyway.

    Separate the RX from the TX and connect them to the PC and use the MicroCode Studio's serial communicator to see if each one is working before connecting them together.

    I believe that it will work with the internal OSC, but you can try with an external osc and see, but...
    Did not see any reference on the internal OSC speed. The default is 4Mhz, but use this:

    Code:
    osccon=%1100111
    DEFINE OSC 4

  2. #2
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    A long time ago Bruce helped me with I2C comms between chips. I was having problems because it was so easy. As an example here is the slave code. I built a board with an address selector switch connected to port C so that I could place them on a Bus without having to reprogram them. The Slaves are monitoring inputs from Volt Free Contacts conected to Port B.

    Code:
    ' PicBasic Pro I2C slave program - PIC16F72/PIC-X1
        ' bootloader and OSC settings
    'DEFINE LOADER_USED 1 ' bootloader
    DEFINE osc 20
    INCLUDE "modedefs.bas"
    
    ' Alias pins
    scl     VAR     PORTC.3         ' I2C clock input
    sda     VAR     PORTC.4         ' I2C data input
    
    
    ' Define used register flags
    SSPIF   VAR     PIR1.3          ' SSP (I2C) interrupt flag
    BF      VAR     SSPSTAT.0       ' SSP (I2C) Buffer Full
    R_W     VAR     SSPSTAT.2       ' SSP (I2C) Read/Write
    D_A     VAR     SSPSTAT.5       ' SSP (I2C) Data/Address
    CKP     VAR     SSPCON.4        ' SSP (I2C) SCK Release Control
    SSPEN   VAR     SSPCON.5        ' SSP (I2C) Enable
    SSPOV   VAR     SSPCON.6        ' SSP (I2C) Receive Overflow Indicator
    WCOL    VAR     SSPCON.7        ' SSP (I2C) Write Collision Detect
    
    
    
    ' Allocate RAM
    result	VAR		BYTE			' ADC result
    datain 	VAR     BYTE			' Data in 
    readcnt	VAR     BYTE            ' I2C read count
    I2Caddress	VAR		BYTE			' Our address	
    
    
    ' Initialize ports and directions
            TRISA = %11111111
    		TRISB = %11111111
    		TRISC = %11111111
    ' Initialize I2C slave mode reading inputs from hardware address settings
            I2Caddress=0
            IF PORTC.0=0 Then I2Caddress=I2Caddress+1
            IF PORTC.1=0 Then I2Caddress=I2Caddress+2
            IF PORTC.2=0 Then I2Caddress=I2Caddress+4
            IF PORTC.5=0 Then I2Caddress=I2Caddress+8
            
            
            SSPADD = I2Caddress		' Set our address
            SSPCON = $36			' Set to I2C slave with 7-bit address
            
    
    While 1>0
          
            While NOT SSPIF
            Wend			' Check for I2C interrupt flag
    
    		SSPIF = 0				' Clear interrupt flag
            IF D_A = 0 Then
            readcnt = 0		' Mark as first read
            EndIF
          
    	
            SSPBUF = PORTB	' Get data from array
            CKP = 1                 	' Release SCL line
            readcnt = readcnt + 1   	' Move along read count
     Wend
    Steve

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. PIC 2 PIC communication
    By Mario in forum Forum Requests
    Replies: 16
    Last Post: - 28th April 2006, 01:56
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45
  5. Pic to Pic communication?
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th April 2004, 19:41

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