Hi,
I am developing on NRF51822 custom board but I had a problem on how to init TWI driver to communicate with MPU6050.
In short, when receiving a BLE_CONNECTED event I trigger a TIMER wih rearming every 2second. Within the timer_timeout_handler I use nrf_drv_twi_tx() and nrf_drv_twi_rx() function to performing I2C READ transaction with NON-BLOCKING mode
However, it seems that my board keeps reseting when I waits for the twi_handler() event. Here is my init code for TWI:
const nrf_drv_twi_config_t twi_mpu6050_config = {
.scl = 3,
.sda = 4,
.frequency = NRF_TWI_FREQ_400K,
.interrupt_priority = APP_IRQ_PRIORITY_HIGH,
.clear_bus_init = false
};
err_code = nrf_drv_twi_init(&m_twi_master, &twi_mpu6050_config, twi_handler, NULL);
APP_ERROR_CHECK(err_code);
nrf_drv_twi_enable(&m_twi_master);
And the twi_tx and twi_rx looks like:
err_code = nrf_drv_twi_rx(&m_twi_master, MP6050_ADDR, &m_sample, sizeof(m_sample));
err_code = nrf_drv_twi_tx(&m_twi_master, MP6050_ADDR, ®, 1, true);
NOTE:
-
I also made sure that the err_code was always 0
-
When I switched back to BLOCKING MODE, this time my board seemed to be loop inside nrf_drv_twi_tx() function
Could you please give me some advice or preference to my case?
Thank you very much, Harlek.