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
  • Hello again, Jack

    Thank you for providing the error message. The error message points to line 147 in Kx132.c - which function returned the error code that was passed to the APP_ERROR_CHECK on this line?

    Also, I thought I should mention that it seems you added the DEBUG tag only to the 'release' build configuration, and not the common build configuration, so if you now build for debug you will still not see these error messages.

    Best regards,
    Karl

Children
Related