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

PWM on nrf52 with mbed consumes to much current.

Hi, I wonder why my pwm uses so much power in WFI mode. It uses around 470uA and when I do not use pwm that current is around 1.8uA. I tried to disable pwm but without success. Here's the code with simple example for what I have tried. I tried to disable GPIOTE, PPI, and all the TIMERS. Thank you.

PwmOut power_power(p5);     
int main(){
    power_power.period(0.00F);
    power_power.write(0.0F);

    NRF_GPIO->PIN_CNF[5] = 0x00000003;  // Disable pull ups, disconnect input buffer, pin as output
    NRF_TIMER0->TASKS_STOP = 1;
    NRF_TIMER0->TASKS_SHUTDOWN = 1;
    NRF_TIMER1->TASKS_STOP = 1;
    NRF_TIMER1->TASKS_SHUTDOWN = 1;
    NRF_TIMER2->TASKS_STOP = 1;
    NRF_TIMER2->TASKS_SHUTDOWN = 1;
    NRF_TIMER3->TASKS_STOP = 1;
    NRF_TIMER3->TASKS_SHUTDOWN = 1;
    NRF_TIMER4->TASKS_STOP = 1;
    NRF_TIMER4->TASKS_SHUTDOWN = 1;
    NRF_PPI->TASKS_CHG[0].DIS = 1;
    NRF_PPI->TASKS_CHG[1].DIS = 1;
    NRF_PPI->TASKS_CHG[2].DIS = 1;
    NRF_PPI->TASKS_CHG[3].DIS = 1;
    NRF_PPI->TASKS_CHG[4].DIS = 1;
    NRF_GPIOTE->TASKS_CLR[0] = 1;
    NRF_GPIOTE->TASKS_CLR[1] = 1;
    NRF_GPIOTE->TASKS_CLR[2] = 1;
    NRF_GPIOTE->TASKS_CLR[3] = 1;
    NRF_GPIOTE->TASKS_CLR[4] = 1;
    NRF_GPIOTE->TASKS_CLR[5] = 1;
    NRF_GPIOTE->TASKS_CLR[6] = 1;
    NRF_GPIOTE->TASKS_CLR[7] = 1;
    
    while(1){
        __WFI();  
    }
}
Related