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

Timer and BLE not working together for nRF52832

Hello Everyone, 

A part of my logic for the module i am developing requires to put the device (nRF52832) in low power mode for xx seconds. Once the timer expires, application wakes up and send the data over BLE and then again goes to low power and so on. 

For this to happen, i am trying to make the BLE and timer work together first but so far i have not been able to achieve any success with that. When i try to run both, it throws an error. 

I followed what was discussed in this page--> https://devzone.nordicsemi.com/f/nordic-q-a/16429/ble-not-working-with-timer-interrupt-rfduino/62864#62864

But changing the priorities also doesn't seem to work. 

Here's my code that i am trying to run: 

nrf_drv_timer_extended_compare(&POWER_TIMER, NRF_TIMER_CC_CHANNEL0, power_timer_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
nrf_drv_timer_enable(&POWER_TIMER);

   nrf_drv_timer_extended_compare(&POWER_TIMER, NRF_TIMER_CC_CHANNEL0, power_timer_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
   nrf_drv_timer_enable(&POWER_TIMER);
    
   while(true)
    {
      if(timer2expired && bleConnected)
      {//timer2expired is true once timer2 expires, bleConnnected is true once connection is established
        do
        {
           length =10;
           err_code = ble_nus_string_send(&m_nus, data, &length);              
           if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY))
            {
              APP_ERROR_CHECK(err_code);
              timer2expired = false;
            }
        }while (err_code == NRF_ERROR_BUSY);
      }

Could you please have a look at the code and suggest where i am going wrong with this. Any suggestions are welcome and will be of great help. 

Thank you! 

SK

Parents Reply
  • Once connected, it throws me this error: 

    <warning> nrf_sdh_ble: RAM starts at 0x20002A68, can be adjusted to 0x20002760.
    <warning> nrf_sdh_ble: RAM size can be adjusted to 0xD8A0.
    <error> ble_gatt: sd_ble_gap_data_length_update() (request) on connection 0x0 returned unexpected value 0x13.
    <info> app: Connected
    <info> app: Data len is set to 0x3D(61)
    <error> app: ERROR 3735928559 [Unknown error code] at zz_path\nordic\nrf52\nRF5_SDK_14.2.0_17b948a\components\drivers_nrf\timer\nrf_drv_timer.c:168

Children
Related