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

(Edit) It is difficult to output the sensor value through the ble_app_uart.

Hello

I am using SDK v17 and nRF52DK board (PCA10040) and testing mpu6050 sensor.

I want to print out the sensor value through the app through ble_app_uart. 

Before sending the sensor values through the app, I would like to test the output at the terminal.
However, there is a problem merging to the ble_app_uart code.

Bluetooth connections work well, but debugging will cause 'NRF_BREKPOINT_COND;'error. Printed at 'err_code = app_mpu_read_accel (& accel_values)

//mpu6050
void mpu_init(void)
{
    ret_code_t ret_code;
    // Initiate MPU driver
    ret_code = app_mpu_init();
    APP_ERROR_CHECK(ret_code); // Check for errors in return value
    
    // Setup and configure the MPU with intial values
    app_mpu_config_t p_mpu_config = MPU_DEFAULT_CONFIG(); // Load default values
    p_mpu_config.smplrt_div = 19;   // Change sampelrate. Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV). 19 gives a sample rate of 50Hz
    p_mpu_config.accel_config.afs_sel = AFS_2G; // Set accelerometer full scale range to 2G
    p_mpu_config.gyro_config.fs_sel = AFS_2G;
    ret_code = app_mpu_config(&p_mpu_config); // Configure the MPU with above values
    APP_ERROR_CHECK(ret_code); // Check for errors in return value 
}


int main(void)
{
    bool erase_bonds;
    uint32_t err_code;


    // Initialize.
    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    
    mpu_init(); //add

    // Start execution.
    printf("\r\nUART started.\r\n");
    NRF_LOG_INFO("Debug logging for UART over RTT started.");
    advertising_start();

    accel_values_t accel_values; //mpu6050
    gyro_values_t gyro_values;

    // Enter main loop.
    for (;;)
    {
        idle_state_handle(); //sleep mode


        //MPU6050 CODE
        if (NRF_LOG_PROCESS() == false)
        {
            //app_mpu_read_accel(&accel_values);
            //app_mpu_read_gyro(&gyro_values);
            
            err_code = app_mpu_read_accel(&accel_values);
            APP_ERROR_CHECK(err_code);
            //err_code = app_mpu_read_gyro(&gyro_values);
            //APP_ERROR_CHECK(err_code);

            //Accel value
            NRF_LOG_INFO("Accel_X : "NRF_LOG_FLOAT_MARKER"", NRF_LOG_FLOAT(accel_x)); //float print
            NRF_LOG_INFO("Accel_Y : "NRF_LOG_FLOAT_MARKER"", NRF_LOG_FLOAT(accel_y));
            NRF_LOG_INFO("Accel_Z : "NRF_LOG_FLOAT_MARKER"", NRF_LOG_FLOAT(accel_z));


            nrf_delay_ms(500);

            //start_accel_update_flag = false;
        }
    }
}
3480.ble_app_uart.zip3312.mpu6050.zip


I attached the project because there may be a problem with other parts.

The mpu6050 was placed in the \nRF5_SDK_17.0.0_9d13099\examples path.

Can you tell me the problem?
Thank you in advance.

================================================ ================================================ ======
Adds output from the debug terminal.

               

Parents
  • Hi,

    The project you uploaded is not buildable as it does not include the MPU code (app_mpu.c/.h), but I assume it is from nrf5-mpu-examples? There is also no usage of the mpu6050 other than the mpu_init() function, so I cannot say much based on that.

    However, I see that the program counter (PC) value when you get the SoftDevice assert is 0x00014cbc. I assume you use S132 7.0.1 (?), and in that case this is caused by the SoftDevice not being able to do a task in due time. A typical reason for this is that you spend too much time in a too high interrupt priority, blocking the SoftDevice for too long.

    Update: reading your question again I wonder if you only get the SoftDevice assert when debugging? If so, then please remember that you cannot continue after a break point or step in the code when using a SoftDevice, as this will cause the SoftDevice to assert because of the reason explained above. So to get the same debugging experience as stepping you need to set a breakpoint and run to that, then move the breakpoint, reset and run again. etc...

  • Hello, Einar!
    Thank you for helping me.

    But I'm still in the same problem.
    Added library file for mpu6050 and added 'mpu_init' to main() code.

    I use SDK v17.0 and Segger, and I worked on s132 of ble_app_uart.

    Can I know more about this problem?

    Thank you.

  • Hi,

    I am no longer able to read the original question. Please edit it again and translate it to English.

    Currently I unfortunately lack context in order to suggest anything. Please share the exact code you are testing so that I know I am looking at the correct code, ans specify which .zip that is. Also, please specify in detail what fails how, and what you would expect. 

Reply Children
No Data
Related