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

After OTA , BMP280 reading switches between 0 and correct values.

I have custom board with BMP280 sensor & nrf 52832.I have interfaced BMP280 using twi interface. I am using SDK 15.2.0. and soft devices s132 V6.1.0 to transmit advertising packets with advertising interval 1s. I had the DFU already working. When I program the application via JLink it works perfectly fine, also the download of the application via secure DFU itself doesn't cause any issues. I have referred following link https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader.


I have read BMP280 after every 5 second. My application starts advertising,but BMP280 reading switches between 0 and correct values continuously. If I programmed application with soft device only(without Secure boot loader) it works fine and bme readings didn't switch between 0 and correct values.

Parents
  • Hi Prashant,

    Do you have a logic analyzer ? If you can capture the TWI communication between the nRF52 and the BMP280 after DFU and compare it with the activity before DFU we can find what could be wrong. 

    Do you have the issue even after you reset the device (after DFU) ? The DFU bootloader shouldn't affect TWI communication. 

  • Thanks for quick reply. No ,I don't have logic analyzer. . The snippet on sensor  code as follows. I have used following code in adv_update function.  I am using GPREGRET2 for storing bmp count .can it be the reason for switching bmp values between 0 and correct values?.

    uint32_t  retain_bmp_cnt[1];
    uint32_t      err_code;
    
    err_code = sd_power_gpregret_get(1,retain_bmp_cnt);
    APP_ERROR_CHECK(err_code);
    		
    		retain_bmp_cnt[0]++;
    if(retain_bmp_cnt[0]>= 5)
    {
    	twi_init();
    	set_configeration();
    	updateData();
    	nrfx_twi_disable(&m_twi);
    	err_code = sd_power_gpregret_clr(1,0xFF);
    	APP_ERROR_CHECK(err_code);
    	err_code = sd_power_gpregret_set(1,0);
    	APP_ERROR_CHECK(err_code);
    }
    else
    {
    	err_code = sd_power_gpregret_clr(1,0xFF);
    	APP_ERROR_CHECK(err_code);
    	err_code = sd_power_gpregret_set(1,retain_bmp_cnt[0]);
    	APP_ERROR_CHECK(err_code);
    }
    	

  • Could you tell why you want to use GPREGRET2 to store the bmp count ? 

    If you simply store the value in a normal variable does it work ? Seems like you are doing a reset every time you get a sample ? If that's the case, our bootloade may erase GPREGRET everytime it's booting up. You need to modify the code to avoid this. 

  • I  used GPRGRET2  to store bmp count because I  have tried store value in normal variable but it doesn't work.

  • What kind of issue do you have ? Storing data to GPREGRET is not the way to go. 

  • I have tested my code. I have observed following points.

    1. I have used  normal variable in adv_update function insted of gprgret2 ,BMP280 reading switches between 0 and correct values after every 5 sec.

    2.  Whenever I called twi_init() in adv_update function with normal variable. I have observed that nrf get soft reset.  I have used following api to find out reset reason.

    sd_power_reset_reason_get(&reset_reason);

    3.  Whenever I called twi_init() in adv_update function with gprgret2. I have observed that nrf get soft reset. 

    4. I have written simple application that just increment variable in adv_update function.  Whenever I used twi_init () (skipped all other sensor  functions) in adv_update function variable did't incremented. If I used twi_init() (skipped all other function ) in main context instead of adv_update function then variable incremented.

  • When you get  a softreset, it means you have an assertion. Please follow this guide to debug it. 

    Most likely you are calling twi_init when you are not supposed to call it. 

Reply Children
Related