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

Problem: Enable Disable UART, ADC peripherals?

Hello to all,

I am using nRF52840 with SES SDK15.0 version. My device is goes into sleep mode after sending data to server. But when woke up device for first reading data successfully send and it will goes into sleep mode. After few minute it wakeup that time not able to ON proper ADC and UART functionality. Also i am struggling for debug because not showing any error it shows only unknown fuction at 0x000978 like this. 

Please help me how i can fix this issue, here is my bellow function for sleep mode:

void stop_adc()
{

    nrf_drv_timer_disable(&m_timer);
    nrf_drv_timer_uninit(&m_timer);
    nrf_drv_ppi_channel_disable(m_ppi_channel);
    nrf_drv_ppi_uninit();
//    NRF_SAADC->TASKS_STOP = 1;
    nrf_drv_saadc_uninit();
}

void sleep_mode_enter()
{
  uint32_t err_code;
  NRF_LOG_INFO("Sleep mode Enter");
  stop_adc();
  err_code = app_uart_close();
  APP_ERROR_CHECK(err_code);                          
//  NRF_LOG_INFO("UART close: %d", err_code);
//  stop_BLE();
}

void startMeasuring_reading()
{
   NRF_LOG_INFO("Measurement started");
   int dataCounter=0;
   int flag = 0;
   int flag2 = -10;
   int flag3 = 0;
   int NextChannelCounter=0;
   int notificationConter = 0;
   int connectionflag = 0;
   uint8_t channel_number = -1;
   bool START_SENDING = false;
   uart_init();
   saadc_sampling_event_init();
   saadc_sampling_event_enable();
}

Also one another thing is i am trying to HIGH and LOW GPIOP0.23 and P0.29 but not able to HIGH this pin why it so. Is it any configuration for access GPIO of nRF52840 DK.

nrf_gpio_cfg_output(23);

nrf_gpio_pin_set(23); // High pin

Is the above code is correct please suggest me proper way or provide program snippet for the above both issues.

Thanks in advanced...

  • Thanks for reply,

    1. Now can i call sleep mode as per following way in main loop;

      for (;;) {
        if (sleep_mode_check == true){
          sleep_mode_enter();
         }
        idle_state_handle();
      }

    If i am wrong please provide proper way for call sleep mode in main loop.

    2. Ok but we have designed custom PCB so in our own PCB this pin(P0.23) should be work is it right???

    Thanks for your suggestion..!!

  • 1. I believe you stop the TIMER, SAADC, and the uart library correctly. I do not know the content of you idle_state_handle function, but it needs to contain the following function calls:
    __WFE();

    __SEV();

    __WFE();

    2. If it does not work on the custom board then there might be something wrong with the schematics/layout or the ESD diode is blown, shorting p0.23 to GND.

    What is the current consumption when p0.23 is driven "high"?

    Do you mind sharing schematics and layout files? I can view Altium, Allegro, Eagle, and raw gerber files with NC drill files. 

  • Hello,

    Sorry for very late reply, We were busy for implementing other functionality and now our application is stable. Now we have getting power consumption issue in sleep mode. Let me describe our measured consumption. 

    We have power profile kit & also digital multi-meter. We are using nRF52840DK and SDK15.0 version to built our application. 

    The measured consumption is 542uA when device is sleep mode means system ON mode.

    This consumption quite very high we should need to optimize to increase battery life because our sensor devices has battery operated. We have turn OFF all used peripheral before goes into sleep mode.

    The following way we have disabled used peripheral is it right?

    void sleep_mode_enter() {
      uint32_t err_code;
      NRF_LOG_INFO("Sleep mode Enter");
      flash_data_sending = false;
      start_measurement = false;
      if ((strcmp((char *)s_info.config_flag, "true") == 0)) { /*Check if config mode enter and called sleep_mode_enter when server request status completed */
        nrf_gpio_pin_set(WIFI_PIN); /*ON WIFI module*/
      } else {
        nrf_gpio_pin_clear(WIFI_PIN); /*OFF WiFi module*/
      }
      nrf_gpio_pin_clear(SENSOR_PIN);  // OFF Sensor
      nrf_gpio_pin_set(GREEN_LED_PIN); // OFF Green LED
      nrf_gpio_pin_set(BLUE_LED_PIN);  // OFF BLUE LED
      stop_adc();
    //  err_code = app_uart_close();
    //  APP_ERROR_CHECK(err_code);
    }
    
    void stop_adc() {
      nrf_drv_timer_disable(&m_timer);
      nrf_drv_timer_uninit(&m_timer);
      nrf_drv_ppi_channel_disable(m_ppi_channel);
      nrf_drv_ppi_uninit();
      NRF_SAADC->TASKS_STOP = 1;
      nrf_drv_saadc_uninit();
    }

    Is the above API and functions right? OR we should need to disabled other way?

    Why this current consumption getting very high in system ON mode? How i can reduced / optimize this consumption?

    We have check no any issue in our hardware. If we put device into system OFF mode that time the current consumption got 5-6 uA which is acceptable.

    Please provide some solution or right way to reduce this consumption.

    Looking forward you response...

    Thanks 

  • I have created new thread for this, so can we continue here

    Thanks for your help..!!

Related