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

Wake up on sensor Event with freeRTOS

Hello 

We have a double problem, the CPU wake up doesn't work, but the sensor who wake up the CPU is correctly configured ant the interrupt pin go low to high when the temperature is ready to read. We see with a scope that this signal is ok but nothing happens with the CPU

Also when we think he is in sleep mode, the current consumption is very high. I think we are not in sleep mode and due to the multithread running the cpu don't catch the interrupt front.

You can see our code 

Thanks for your support


#define SHUTDOWN_LEVEL_MEAS_INTERVAL            500                         /**< Shutdown interval (ms). */
#define OSTIMER_WAIT_FOR_QUEUE                  2                           /**< Number of ticks to wait for the timer queue to be ready */
static TimerHandle_t m_shutdown_timer_id;                                   /**< Definition of shutdown timer. */
void in_pin_hdc2080_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
    if(pin == HDC2080_INT_PIN) {
        setSignalHDC2080();
        // Start shutdown timer timers.
        if (pdPASS != xTimerStart(m_shutdown_timer_id, OSTIMER_WAIT_FOR_QUEUE))
        {
            APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
        }
    }
}
/**
 * @brief Handler for timer events.
 */
void timer_shutdown_event_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
    APP_ERROR_CHECK(sd_power_system_off());
}
void gpio_init(void)
{
    ret_code_t err_code;
    // Initialize GPIOTE module.
    APP_ERROR_CHECK(nrf_drv_gpiote_init());
    // Initialize timer module.
    APP_ERROR_CHECK(app_timer_init());
     // Create timers.
    m_shutdown_timer_id = xTimerCreate("SHUT",
                                   SHUTDOWN_LEVEL_MEAS_INTERVAL,
                                   pdTRUE,
                                   NULL,
                                   timer_shutdown_event_handler);
    //VDD activation for HDC2080 sensor
    nrf_gpio_cfg_output(HDC2080_VDD_PIN);
    nrf_gpio_pin_clear(HDC2080_VDD_PIN);
    //Sense mode for HDC2080
    nrf_drv_gpiote_in_config_t in_config = NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_NOPULL;
    APP_ERROR_CHECK(nrf_drv_gpiote_in_init(HDC2080_INT_PIN, &in_config, in_pin_hdc2080_handler));
    //nrf_gpio_cfg_sense_input(HDC2080_INT_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
    nrf_drv_gpiote_in_event_enable(HDC2080_INT_PIN, true);
}
  • Hi,

    Regarding the first issue with wakeup, your code seems sensible. You configure the GPIO pin as input with with sense, so it should work as a wakeup source from system OFF. Then you call sd_power_system_off().

    The fact that you see a high current consumption could indicate that an error handler has been hit. Can you check with a debugger if that is the case? If so and debug is defined, the system will stay in the error handler. Alternatively, if DEBUG is not defined, there will be a reset. This would explain why there is no wakeup.

    An alternative explanation for high current consumption in system OFF, is if you have a debugger attached. In that case, the nRF will not actually go into system off, but rather emulated system off which is essentially just an eternal loop.

Related