This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf51 TWI burst write error

Hi everybody,

Chip: nRF51422

Board: PCA10028

Firmware: S130_nRF51_2.0.1

The system hangs when doing burst write reg. MPU9255 can work fine if all writes are [reg, data[0]]; How to solve the problem?

uint32_t i2c_write(unsigned char addr, unsigned char reg, uint32_t length, unsigned char* data){
    uint32_t err_code;
    uint32_t timeout = MPU_TWI_TIMEOUT;

    //--work around for multi register data write
    uint8_t *packet;
    packet[0] = reg;
    memcpy((packet+1),data,length);

	err_code = nrf_drv_twi_tx(&m_twi_instance0, MPU_ADDRESS, packet, length+1, false);
	
	if(err_code != NRF_SUCCESS) return err_code;

    while((!twi_tx_done) && --timeout);
    if(!timeout) return NRF_ERROR_TIMEOUT;

    twi_tx_done = false;
    return NRF_SUCCESS;  }
Parents Reply Children
No Data
Related