This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PCF8574A IO Expander with nRF52-DK

Hi,

I'm trying to use PCF8574A IO Expander with a nRF52-DK board to display characters on an HD44780 LCD. I noticed that I have to use the function nrf_drv_twi_tx(). Since PCF8574A doesn't have a register address, how do I send commands and text to the LCD?

Thanks

Parents
  • The PCF8574A has an address, it has to have an address, it's an I2C device, I2C requires things to have an address. The address is whatever you set up on the A0-A2 pins.

    So you give the command the address of the expander and write a byte of data.

    I do have to ask however, since you have an nRF52 development kit which has masses of output lines just begging to be used, why do you need a port expander? Port expanders are for arduinos which come with about 1 1/2 pins available.

  • Oh, ok, thanks RK. The reason I want to use an IO Expander is that I will be using the nRF52-DK in a big project and multiple I2C devices, so I want to make it neat.

    I know my device address is 0x38, but as Alex pointed out I thought register address is a necessary parameter to use in order to use TWI function.

    Now, when I looked up nrf_drv_twi_tx() function, the parameter that you send data is declared as "uint8_t const *". So can I use the TWI function in the following way?

    static ret_code_t expanderWrite(uint8_t buffer)
    {
    
    return nrf_drv_twi_tx(&m_twi_hd44780, hd44780_ADDR, &buffer, sizeof(buffer), false);
    
    }
    

    passing data as reference &buffer?

Reply
  • Oh, ok, thanks RK. The reason I want to use an IO Expander is that I will be using the nRF52-DK in a big project and multiple I2C devices, so I want to make it neat.

    I know my device address is 0x38, but as Alex pointed out I thought register address is a necessary parameter to use in order to use TWI function.

    Now, when I looked up nrf_drv_twi_tx() function, the parameter that you send data is declared as "uint8_t const *". So can I use the TWI function in the following way?

    static ret_code_t expanderWrite(uint8_t buffer)
    {
    
    return nrf_drv_twi_tx(&m_twi_hd44780, hd44780_ADDR, &buffer, sizeof(buffer), false);
    
    }
    

    passing data as reference &buffer?

Children
No Data
Related