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

nrf52832 DCDC & __WFE problem

Hi, I am editing my question:

I have seen some strange behaviuor I could not explain. In order to test it I have made the next test program: I am using the application timer module to create 2 timers: one timer of 33.3 ms in repeat mode, and another of 2 ms in single shot mode, which is triggered once inside the 33.3 ms cycle (my code is attached below). inside the 2 ms timer I put the CPU to low power mode, using __WFE.

when I work with the debugger connected, I see the expected behaviour (see Logic image:) image description

but when I run the program without the debugger connected, this is what I get (program is stack after a few cycles): image description

I have also noticed that disabling __WFE in the 2 ms loop, or disabling the dc-dc solves this issue (see Logic images)

no WFE: image description

no dc-dc: image description

this is my code:

void timers_create(void)
{
  // Initialize timer module.
  APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS,    APP_TIMER_OP_QUEUE_SIZE, false);
  
  // Create timer for cycles (33.3 ms)
  g_err_code = app_timer_create(&m_cycle_timer_timer_id, APP_TIMER_MODE_REPEATED, cycle_timeout_handler);
  APP_ERROR_CHECK(g_err_code);
 
  // Create timer for delays
  g_err_code = app_timer_create(&m_delay_timer_id, APP_TIMER_MODE_SINGLE_SHOT, delay_timeout_handler);
  APP_ERROR_CHECK(g_err_code);
}



void cycle_timer_start(void)
{
  g_err_code = app_timer_start(m_cycle_timer_timer_id, CYCLE_INTERVAL, NULL);
  APP_ERROR_CHECK(g_err_code);
}

void main()
{
  NRF_POWER->DCDCEN = 1;  
  
  g_err_code = nrf_drv_clock_init(NULL); 
  APP_ERROR_CHECK(g_err_code);
  
  // start LFCLK
  nrf_drv_clock_lfclk_request();  
  
  timers_create();  
  
  nrf_gpio_cfg_output(25); 
  nrf_gpio_pin_clear(25);

  nrf_gpio_cfg_output(26); 
  nrf_gpio_pin_clear(26);  

  cycle_timer_start();  // 33 ms cycle
 
  while(1)
  {
    // wait for fglag
    while(!g_activate_flag)  {};
    
    nrf_gpio_pin_toggle(25);
    g_activate_flag = false;
    
    // delay timer start
    app_timer_start(m_delay_timer_id, 66, NULL);
    nrf_gpio_pin_set(26);
  
  
    while (!g_delay_ended)
    {
      // Wait for event 
      __WFE();      
    }  
  
    g_delay_ended = false;
    nrf_gpio_pin_clear(26);
  }  
}

Can someone explain this behaviour? Thanks Yaron

Parents
  • Hi,

    There is a PAN in Rev A and B chips. I see that PAN63 describes part of it but not completely. When you enable DCDC and go to sleep without any peripherals using HFCLK, then the _WFE instruction will release the HFCLK and the DCDC converter drops down on voltage.

    You can easily fix this in your code by disabling DCDC before going to system IDLE and enabling it when it wakes up.

      // Disable DCDC converter
      NRF_POWER->DCDCEN = 0;
    
      while (!g_delay_ended)
        {
          // Wait for event 
          __WFE();      
        } 
    
       // Disable DCDC converter
       NRF_POWER->DCDCEN = 1;
    

    This has been fixed in Rev C and I tested it on Rev C to confirm it (thanks to Håkon for quickly soldering RevC chip for test).

Reply
  • Hi,

    There is a PAN in Rev A and B chips. I see that PAN63 describes part of it but not completely. When you enable DCDC and go to sleep without any peripherals using HFCLK, then the _WFE instruction will release the HFCLK and the DCDC converter drops down on voltage.

    You can easily fix this in your code by disabling DCDC before going to system IDLE and enabling it when it wakes up.

      // Disable DCDC converter
      NRF_POWER->DCDCEN = 0;
    
      while (!g_delay_ended)
        {
          // Wait for event 
          __WFE();      
        } 
    
       // Disable DCDC converter
       NRF_POWER->DCDCEN = 1;
    

    This has been fixed in Rev C and I tested it on Rev C to confirm it (thanks to Håkon for quickly soldering RevC chip for test).

Children
Related