1 2 Previous Next 15 Replies Latest reply on Apr 26, 2016 12:46 AM by user_347933176

    I2C Slave operation

    wbasser_1635821

      I have an I2C slave and an I2C master instantiated on a CY8C42 processor.  I have the SDA/SCL pins tied together with a 2200 ohm pullups to 3.3v.  externally.

         

      The pins that are being used are P3.0-P4.0 and P3.1-P4.1.  I have set up the slave for an address of 0x58 and using the same address in a send start command, I can visually see the address go out but the slave does not acknowledge the transmission.

         

      Code snippets are as follows:

         

      Slave initialization:

         

        // initialize the TX/RX buffer
        I2CSlave_I2CSlaveInitReadBuf( anTxBuffer, MAX_XMT_BUFFER_SIZE );
        I2CSlave_I2CSlaveInitWriteBuf( anRxBuffer, MAX_RCV_BUFFER_SIZE );

         

        // initialize the SBC_I2C
        I2CSlave_Start( );
        
        // set the interrupt handler
        I2CSlave_SetCustomInterruptHandler( LocalIrqHandler );
        
        // force an address ( added just in case )
        I2CSlave_I2CSlaveSetAddress( 0x58 );

         

        // enable the interrupts
        I2CSlave_SetSlaveInterruptMode( I2CSlave_INTR_SLAVE_I2C_ARB_LOST |
                                        I2CSlave_INTR_SLAVE_I2C_NACK |
                                        I2CSlave_INTR_SLAVE_I2C_ACK |
                                        I2CSlave_INTR_SLAVE_I2C_WRITE_STOP |
                                        I2CSlave_INTR_SLAVE_I2C_STOP |
                                        I2CSlave_INTR_SLAVE_I2C_START |
                                        I2CSlave_INTR_SLAVE_I2C_ADDR_MATCH |
                                        I2CSlave_INTR_SLAVE_I2C_BUS_ERROR );

         

        // enable the intrrupt
        I2CSlave_EnableInt( );

         

       

         

      Master initialization and transmission:

         

      // start the I2C
        I2CMaster_Start( );
        
        // for debug only
        uStatus = I2CMaster_I2CMasterClearStatus( );
        uStatus = I2CMaster_I2CMasterSendStart( 0x58, I2CMaster_I2C_WRITE_XFER_MODE );
        if ( uStatus == I2CMaster_I2C_MSTR_NO_ERROR )
        {
          // now send a byte
          uStatus = I2CMaster_I2CMasterWriteByte( 0x1E );
          if ( uStatus == I2CMaster_I2C_MSTR_NO_ERROR )
          {
          }
        }

         

      The first usuable status on send start returns a 0x0002.

         

      Any ideas would be appreicated.

        1 2 Previous Next