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

gpio driver configuration

I'm trying to lighten the leds using ble, my problem is that when I measure the current consumption when the leds command sent, it reaches to 5mA which is not suitable for my application, I read on the DK user guide & the power measurement does not include the leds power, besides, I read on the datasheet that that may be due to pin drivers, how can I reduce the current in that case ? ? ?

  • I tried to use some sort of : NRF_GPIO->PIN_CNF[6] |= (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos); NRF_GPIO->PIN_CNF[7] |= (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos);

    but nothing of the leds turned on....

  • I assume you are applying voltage to the external supply pins (or using a battery) and that you are measuring current over P22, which will only give you the current going in to the nRF chip. Have a look at this tutorial on how to set up the kit for measurements: devzone.nordicsemi.com/.../

    Note that powering from USB will induce a lot of noise and you will not get good measurements.

    The LEDs are powered by the V_IO line, which is not the same as the one you are measuring over (VDD_nRF, P22), so the current drawn by the LED should not be included in your measurements. This goes for both PCA10028 (nRF51) and PCA10040 (nRF52).

    Remember that you have to set the GPIO output low to turn on the LED. This means that you will pull the nRF side of the LED to ground, and that current will flow from V_IO to ground, not affecting the nRF current measurement.

    Also put the CPU to sleep in main loop, or else it will draw several milliamps.

    This will turn on LED1 on the PCA10028:

    int main(void)
    {
        NRF_GPIO->PIN_CNF[21] |= 1;     // set as output
        NRF_GPIO->OUTSET &= !(1 << 21); // set low
        while (true)
        {
            __WFE();                    // CPU in sleep
        }
    }
    

    My measurements on the PCA10028 with this code gives about 2.5 uA for both LED on and off.

    Note that the debugger should be disconnected and the chip power cycled to get out of debug mode, which (in my case) draws 1.2 mA current. If you are using the USB and onboard debugger, this means disconnecting the USB, and power cycling the board

Related