Menu

HI2C Write/Read Adreess

Help
MBB
2023-03-14
2023-03-16
  • MBB

    MBB - 2023-03-14

    I'm using this https://www.adafruit.com/product/4481

    In the Specification it says:

    6.32.8 Registers - page 491
    Base address Peripheral Instance Description
    0x40003000 TWIS TWIS0 Two-wire interface slave 0
    0x40004000 TWIS TWIS1 Two-wire interface slave 1
    '**********

    6.32.8.29 ADDRESS[n] (n=0..1) - page 500

    Address offset: 0x588 + (n × 0x4)

    TWI slave address n
    '**********

    Does the base address 0x40003000 get added to the 0x588 to create 0x40003588 for TWIS0?

    Since I2C uses byte size numbers, do I send 4 bytes to address the chip?

    I believe the 0x40003588 gives a 7-bit I2C address. What would be the Write and Read 8-bit address' be?

     
    • Anobium

      Anobium - 2023-03-14

      Are you using this device as the I2C master?

      How does 0x40003588 relate to a 7 or 8 bit addressing? 7 bit are range 0 to 127 and 8 bit range is 0 to 255.

       
    • mmotte

      mmotte - 2023-03-15

      Looking at Adafruit ItsyBitsy nRF52840 Express - Bluetooth LE
      Product ID: 4481 .

      this already has a processor onboard and can communicate using BLE. It can be programmed by the Arduino programmer or circuit python which is like micro python and a usb cable. The I2C is for talking to other modules.

      I am not sure what you are trying to do?

      GL
      M

       
      👍
      1
  • MBB

    MBB - 2023-03-15

    Are you using this device as the I2C master?
    I'm using the device as a slave.

    How does 0x40003588 relate to a 7 or 8 bit addressing? 7 bit are range 0 to 127 and 8 bit range is 0 to 255.
    To get the 8-bit Write/Read you shift the 7-bit I2C address left one bit.
    I don't know what to do with 0x88 in the base address. 0x88 = 136 decimal = b1000 1000. When I shift it left it becomes 1 0001 0000 = 272 - A word value. So, does the 0x35 become 0x36? Or do I shift the whole base 0x40003588 making it 80006B10?
    In any case, I've tried all this and it didn't work.

    The below is the code I was trying to make work:

      '0x40003000 is BASE ADDRESS for Two-wire interface slave 0 pg 491 & 501
    #define nRF52840_Base_Address_MSB 64 ;0x40
    #define nRF52840_Base_Address_LSB 0
    
    #define nRF52840_Sensor_Write_Addr_MSB 53 ;0x3 & 0x588  7-BIT Address offset: 0x588 + (n × 0x4)
    #define nRF52840_Sensor_Write_Addr_LSB 136
    
    #define nRF52840_Sensor_Read_Addr_MSB 53 ;0x3 & 0x588  7-BIT Address offset: 0x588 + (n × 0x4)
    #define nRF52840_Sensor_Read_Addr_LSB 137
    
    #define ENABLE_I2C_MSB 53 ;0x3500 Enable I2C
    #define ENABLE_I2C_LSB 0
    

    Is this how to WRITE to the device?
    HI2CStart
    HI2CSend nRF52840_Base_Address_MSB
    HI2CSend nRF52840_Base_Address_LSB
    HI2CSend nRF52840_Sensor_Write_Addr_MSB
    HI2CSend nRF52840_Sensor_Write_Addr_LSB
    HI2CSend ENABLE_I2C_MSB ;pg 497
    HI2CSend ENABLE_I2C_LSB
    HI2CSend 15 ;RW Pin & RW Port - Bits 0 to 7
    HI2CSend 0 ;Bits 8 to 15
    HI2CSend 0 ;Bits 16 to 23
    HI2CSend 0 ;Bits 24 to 31
    HI2CStop

    Is this how to READ data from the device?
    HI2CStart
    HI2CSend nRF52840_Base_Address_MSB
    HI2CSend nRF52840_Base_Address_LSB
    HI2CSend nRF52840_Sensor_Write_Addr_MSB
    HI2CSend nRF52840_Sensor_Write_Addr_LSB
    HI2CSend ENABLE_I2C_MSB ;pg 497
    HI2CSend ENABLE_I2C_LSB
    HI2CReStart
    HI2CSend nRF52840_Base_Address_MSB
    HI2CSend nRF52840_Base_Address_LSB
    HI2CSend nRF52840_Sensor_Read_Addr_MSB
    HI2CSend nRF52840_Sensor_Read_Addr_LSB
    HI2CSend ENABLE_I2C_MSB ;pg 497
    HI2CSend ENABLE_I2C_LSB
    HI2CReceive Enab_1
    HI2CReceive Enab_2
    HI2CReceive Enab_3
    HI2CReceive Enab_4, NACK
    HI2CStop

          locate 0, 17
          print Enab_1
    
            locate 1, 17
            print Enab_2
    
              locate 2, 17
              print Enab_3
    
                locate 3, 17
                print Enab_4
    
     
  • Anobium

    Anobium - 2023-03-15

    I would use I2CDiscovery program to show this Slave device. The address can only be in the range of 0 to 255 - so, it is really hard to advice with respect to the addressing as transformation of 0x40003588 is meaningless to me.

     
  • MBB

    MBB - 2023-03-16

    Thanks!

     

Log in to post a comment.