Error with the faster period of 50ms in I2C/twi reading

 Hello Groups,

I'm trying to send I2C/twi data from nRF52832 using the Nordic development board with nRF Connect SDK 1.9.1.

Based on the sample project ble_app_uart, I read and added the I2C data of the accelerometer KX132 and sending out through the BLE mechanism.

It worked very well with reading and sending I2C data fast to the period, down to 60ms. But when I tried to send faster by setting the period down to 50ms then, I got the error at the function:

   __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)

At

     NRF_BREAKPOINT_COND;

Any idea on this problem?

Thanks a lot for your time,

Jack

///////// code

// Note: In my application, I need to read the I2C fast to clear the FIFO buffer of the sensor.

#define SENSOR_RATE_MEAS_INTERVAL       APP_TIMER_TICKS(50)

static void application_timers_start(void)                     

{

    ret_code_t err_code;

 

    // Start application timers.

    err_code = app_timer_start(m_sensor_rate_timer_id, SENSOR_RATE_MEAS_INTERVAL, NULL);

    APP_ERROR_CHECK(err_code);

 

}

void twi_init(void)

{

       ret_code_t err_code;

 

       const nrf_drv_twi_config_t twi_sensor_config = {

          .scl = ARDUINO_SCL_PIN,

          .sda = ARDUINO_SDA_PIN,

          .frequency = NRF_DRV_TWI_FREQ_400K,

          .interrupt_priority = APP_IRQ_PRIORITY_HIGH,

          .clear_bus_init = false

       };

 

       err_code = nrf_drv_twi_init(&m_twi, &twi_sensor_config, twi_handler, NULL);

       APP_ERROR_CHECK(err_code);

 

       nrf_drv_twi_enable(&m_twi);

}

 

static void sensor_meas_timeout_handler(void* p_context)  

{

    // prepare data

    uint16_t length = PACKAGE_BLE_MAX_SIZE;

    ret_code_t      err_code;

 

    UNUSED_PARAMETER(p_context);

    kx132ReadFifo();

 

    err_code = ble_nus_data_send(&m_nus, BlePackageData, &length, m_conn_handle);

    if ((err_code != NRF_ERROR_INVALID_STATE) &&

        (err_code != NRF_ERROR_RESOURCES) &&

        (err_code != NRF_ERROR_NOT_FOUND))

    {

        APP_ERROR_CHECK(err_code);

    }

 

}

Parents Reply Children
No Data
Related