+ Reply to Thread
Results 1 to 2 of 2

Thread: I2C Pic to Pic

  1. #1
    Voltak Newbie
    Join Date
    Jun 2009
    Location
    Belgium
    Posts
    1

    I2C Pic to Pic

    This program is for a Pic16f877a (slave) who communicates with another pic16f877a (master), writed in Mikrobasic.

    Code:
    program slave 
    
    sub procedure interrupt 
    if PIR1.SSPIF = 1 then 
    PORTB=%00000000 
    delay_ms(2000) 
    PIR1.SSPIF=0 
    end if 
    End sub 
    
    main: 
         trisc=$ff                      
         trisb=0                        
    
         adcon1=0                      
         sspcon=%00110110              
                                      
                                      
         sspadd=$A2                
         PIE1.SSPIE=1                
         PIR1.SSPIF=0                
                                    
         intcon =192                  
    
    
         while true 
         Portb=%11111111 
         wend 
    
    end.
    
    My question is of this works, and when I write I2C_rd() in the interrupt proces, can read the data of the master?


  2. #2
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,696

    That code makes no sense. Find an example that works and work from that.

    Mike.

+ Reply to Thread

Tags for this Thread