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

TWI only sending slave address, no data

Hello, I'm quite new to both the nRF52832 and the Segger Embedded Studio. I have a college project which involves I2C communication with 2 slaves. I was finally able to set up some sort of activity on the SDA and SCL pins, however, it appears that only the slave address gets transmited, no data. Of course I assume that I'm calling the function in the wrong way somehow, but I'm having a hard time understanding thow all the libraries work together. I have compared my code with the one used in the twi_sensor project, but I don't understand what I do wrong. Your help would be much appreciated.

#include <stdio.h>
#include "nrf_delay.h"
#include "nrfx_twi.h"

const nrfx_twi_t m_twi = NRFX_TWI_INSTANCE(0);
const uint8_t address = 0x00;
uint8_t data = 0xAA;

void twi_init(void)
{
  const nrfx_twi_config_t twi_config =
  {
    .scl                = 27,
    .sda                = 26,
    .frequency          = NRF_TWI_FREQ_100K,
    .interrupt_priority = NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY,
    .hold_bus_uninit     = false,
  };

  nrfx_twi_init(&m_twi,&twi_config,NULL,NULL);
  nrfx_twi_enable(&m_twi);
}

void main(void)
{
  twi_init();

  while (1)
  {
    nrfx_twi_tx(&m_twi,address,&data,sizeof(data),false);
    nrf_delay_ms(5000);
  }
}

Could it be because there is no acknoledge? (I'm probing without a slave to answer, I'm just testing the functions I will need)

Related