HI2CSetAddress

Syntax:

    HI2CSetAddress address_number

Command Availability:

Only available for microcontrollers with the hardware I2C or TWI module.

Explanation:

Sets the microcontroller address number in Slave mode.

Only used in slave mode.

Note:

This command is also available on microcontrollers with a second hardware I2C port.

    HI2C2SetAddress address_number

Example:

    #chip 16F1937, 32

    HI2CMode Slave
    HI2CSetAddress 0x60          ' <<< the HI2CSetAddress instruction

    Do
        'Wait for the master to address this device at 0x60
    Loop

Key line: HI2CSetAddress 0x60 — sets this device’s own I2C address to 0x60, so it only responds when a master addresses that specific value.

See Also:

  • HI2C Overview — category overview
  • HI2CMode — selecting slave mode before setting an address
  • HI2CReceive — receiving data addressed to this device

Supported in <HI2C.H>