Communication i2c pic18f26k22
Répondre à la discussion
Affichage des résultats 1 à 3 sur 3

Communication i2c pic18f26k22



  1. #1
    invite54878a5a

    Communication i2c pic18f26k22


    ------

    Bonjour,

    Je reviens vous voir car j'ai un problème de communication i2c. Le maitre i2c est une carte embeddian, sur le bus se trouve une mcp23017 ainsi que mon pic18f26k22.
    Avec i2cdetect le pic et le mcp sont bien détectés. J'ordonne au mcp d'allumer son port a, cela fonctionne. Je reprends le meme programme mais avec l'adresse destination mon pic.
    Le seul retour que j'ai est, sur le port série :
    INIT();
    INIT();
    INIT();
    Interrupti2c!
    Value - H -

    Le pic reçoit bien l'interruption, mais je ne récupère aucune data...

    #include <p18f25k22.h>
    #include <usart.h>
    #include <delays.h>
    #include <i2c.h>

    void Serial_Init(void) {
    ANSELC=0;
    TRISCbits.TRISC6 = 0;
    TRISCbits.TRISC7 = 1;
    Open1USART( USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 129 );
    RCONbits.IPEN = 1;
    IPR1bits.RCIP=0;
    PIE1bits.RCIE=1;
    INTCONbits.GIEL = 1;
    INTCONbits.GIEH = 1;
    }
    void Serial_Putchar(unsigned char cD) {
    putc1USART(cD);
    }
    void Serial_Putstring(const unsigned char mess[]) {
    putrs1USART(mess);
    }


    void ISR(void);

    #pragma code H_vector=0x08
    void H_vector(void) { _asm goto ISR _endasm }
    #pragma code

    #pragma interrupt ISR
    void ISR(void) {
    if (PIR1bits.SSPIF==1){
    Serial_Putstring("Interrupti2c !\r\n");
    if (DataRdyI2C1()==1) {
    char c = ReadI2C1();
    Serial_Putstring("Value :-");
    Serial_Putchar(c);
    Serial_Putstring("-\r\n");
    SSPBUF = 0;
    SSPCON1bits.WCOL=0;
    }
    PIR1bits.SSPIF = 0;
    SSPCON1bits.CKP = 1;
    }
    }

    void main() {
    ANSELC = 0;
    TRISC = 255;
    INTCONbits.GIEH = 0;
    RCONbits.IPEN = 1; // Enable interrupt priorities
    IPR1bits.SSPIP = 1; // Set SSP interrupt priority to high
    PIR1bits.SSPIF = 0; // Clear the interrupt flag
    PIE1bits.SSPIE = 1; // Enable SSP interrupt
    INTCONbits.GIEH = 1;
    SSPADD = 0x10<<1;
    SSPCON2 = 0b00000000;
    SSPCON1bits.CKP = 0;
    SSPSTATbits.BF=0;
    SSPCON1bits.SSPOV=0;
    Serial_Init();
    IdleI2C();
    OpenI2C(SLAVE_7 , SLEW_OFF);
    Serial_Putstring("INIT()\r\n") ;
    Serial_Putstring("INIT()\r\n") ;
    Serial_Putstring("INIT()\r\n") ;
    while(1) {
    }
    }


    Si vous aviez une idée, je suis preneur

    Merci

    -----

  2. #2
    RISC

    Re : Communication i2c pic18f26k22

    Salut,
    Peux-tu reposter ton code en utilisant les balises code pour qu'il soit lisible ?
    Es-tu sur que tu as implémenté le protocole I2C correctement ?
    a+

  3. #3
    invite54878a5a

    Re : Communication i2c pic18f26k22

    Salut

    J'ai réussi à m'en sortir pour ce problème là, l'autre problème que j'ai c'est que l'interruption est déclenchée peut importe l'adresse envoyée par le maitre. est-ce normal? Biensur j'ai mis une adresse différente dans SSPAD que celle qu'envoie le maitre et pourtant le pic croit que c'est pour lui

Discussions similaires

  1. Power Line communication sur une ligne DC. Communication CAN
    Par invitee2723b34 dans le forum Électronique
    Réponses: 3
    Dernier message: 21/02/2012, 11h28
  2. communication USB
    Par invite8662404b dans le forum Électronique
    Réponses: 2
    Dernier message: 26/04/2010, 14h03
  3. communication
    Par invite5a90430f dans le forum Orientation après le BAC
    Réponses: 3
    Dernier message: 11/08/2007, 14h38
  4. ADN - et communication
    Par invite3d34a963 dans le forum Biologie
    Réponses: 12
    Dernier message: 31/07/2007, 10h34
  5. communication
    Par invite7f5e7850 dans le forum Technologies
    Réponses: 2
    Dernier message: 09/07/2006, 13h40
Dans la rubrique Tech de Futura, découvrez nos comparatifs produits sur l'informatique et les technologies : imprimantes laser couleur, casques audio, chaises gamer...