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

How to verify my application has enter sleep mode? My freeRTOS task PWM stop working after runs for a few second.

Hi,

HW:customized nRF52840 board

SW: nRF5_SDK_15.2.0_9412b96

Application: modified blinky_rtc_freertos example (PWM led + freeRTOS task)

Q1) How to verify my application has enter sleep mode? My freeRTOS task PWM stop working after runs for a few second.

Q2) If my application enter sleep mode, I want to know which sleep mode I enter(softdevice deep sleep? Or FreeRTOS tickless idle mode/Sleep) as my code always at while loop inside the task.

Q3) How do I ensure when PWM led is running the device won't enter sleepmode for softdevice/FreeRTOS tickless idle?

void demo1 (void * pvParameter)
{
    UNUSED_PARAMETER(pvParameter);


    /*
     * This demo plays back a sequence with different values for individual
     * channels (LED 1 - LED 4). Only four values are used (one per channel).
     * Every time the values are loaded into the compare registers, they are
     * updated in the provided event handler. The values are updated in such
     * a way that increase and decrease of the light intensity can be observed
     * continuously on succeeding channels (one second per channel).
     */

    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            LED_RED | NRF_DRV_PWM_PIN_INVERTED, // channel 0
            LED_BLU | NRF_DRV_PWM_PIN_INVERTED, // channel 1
            LED_GRN | NRF_DRV_PWM_PIN_INVERTED,  // channel 2
//            BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // channel 0
//            BSP_LED_1 | NRF_DRV_PWM_PIN_INVERTED, // channel 1
//            BSP_LED_3 | NRF_DRV_PWM_PIN_INVERTED, // channel 2
            NRF_DRV_PWM_PIN_NOT_USED  // channel 3
        },
        .irq_priority = APP_IRQ_PRIORITY_LOWEST,
        .base_clock   = NRF_PWM_CLK_2MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = m_demo1_top,
        .load_mode    = NRF_PWM_LOAD_COMMON,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    nrf_drv_pwm_uninit(&m_pwm0);
    APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, demo1_handler));

    m_used |= USED_PWM(0);

    m_demo1_seq_values.channel_0 = 0;
    m_demo1_seq_values.channel_1 = 0;
    m_demo1_seq_values.channel_2 = 0;
    m_demo1_seq_values.channel_3 = 0;
    m_demo1_phase                = 0;

    (void)nrf_drv_pwm_simple_playback(&m_pwm0, &m_demo1_seq, 1,
                                      NRF_DRV_PWM_FLAG_LOOP);
    uint8_t sample_data;
    uint8_t config = 0x06;
    while(1)
    { 
   };
}

  • Hi Ing,

    1. Connect it to a power consumption measuring device or a power profiler kit from Nordic to verify if there is a voltage drop happening in between processing. Also read about this.
    2. If you have enabled Tickless idle mode then it is system on idle sleep (WFE). If not then your application has to call either __WFE or sd_app_evt_wait() based on whether you are using softdevice or not.
    3. I did not quite understand your question. When you can see your LEDs dimming in and out, you know that PWM is not in sleep mode. why do you want to keep the whole system on while the PWM is doing its job in the background while the system could be in sleep?
  • Hi Aryan,

    Thanks. We managed to find out there are some interference in one of our power management ic which cause the device to reset its register. But still the info about how I could know how to check is the device enter tickless idle is useful.

    Thanks a lot. I will close this case.

Related