Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Properly configuring the GPIOs ?

Hello all, 

I am porting the code from the nrf52dk to the nrf52820 based module and so far so good!

However, I can blink the LED on certain pins while not on the others, so I am thinking, am I not doing something right, for example, the hardware has a proper, healthy connection.

Working on the nRF52DK and Segger with the nRF5SDK, the module PAN1781 is programmed ok via the SW .. all good, maned to program the blinky10100e example ...

Now, the other GPIO would like to be used, namely the F3 and F7 (see more here New Output (panasonic.de ) , but although the following code works, for example, I can change the GPIOs I cannot get the led blink!

#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "boards.h"

#define GPIO_LED_EXTERNAL 20  //my gpio
#define BLINK_DELAY 200


/**
 * @brief Function for application main entry.
 */
int main(void)
{
    /* Configure board. */
   nrf_gpio_cfg_output(GPIO_LED_EXTERNAL);

    /* Toggle LEDs. */
    while (true)
    {
      nrf_gpio_pin_toggle(GPIO_LED_EXTERNAL);
      nrf_delay_ms(BLINK_DELAY);
      printf("Blinking the led on pin: %d\n", GPIO_LED_EXTERNAL);
    }
}

I am wondering, if the GPIOs have to be defined differently? For example, I would like to put the TWI on some of those GPIOs... apropos TWI, I have tried to use the GPIOs where the led can be blinked for the TWI namely scl and sda, but cannot get it to work, otherwise the code compiles ok, and it was ported from the nrf52dk where all seamlessly work.

Any Ideas?

Best.

Parents
  • Hi,

    The minimal code you have shown should work for toggling any GPIO by just changing the GPIO_LED_EXTERNAL. All GPIOs should work with this out of the box, except for a few special ones (on devices with NFC you would need to configure the UICR if using the NFC pins, but that in snot relevant on the nRF52820).

    Are you testing and getting it to fail with the simple test program in your initial post? If so, which pins have you tested that works and which have you tested that do not work? How are these pins configured on the HW / board? Could it be that some are tied to ground or VDD, for instance? Perhaps you can share a schematic? Also, which exact module are you using?

  • Hello Einar

    Thank you for your reply, question, namely interest.

    Yes, I am testing the led blinking on different GPIOs, namely the one that I have available. These are : P0,14, P0.20, P0.13, P0.02 and P0.08 . I have blinked the led via resistor on pins 14, 20 and 2, the pins 13 and 8 are not working. All of the GPIOs were tested, if they are healthy, and they are.

    Yes, we have the PAN1781 module (based on nrf52820) and the prototype is designed , if you look at the el. schematics you will see that the original names that are targeted are: E1, E2, F3, F5, F7, indeed, the F3 and F7 are not working.

    No pins are tied to any GND or VDD, with regard to the schematic I can share a simple drawing, anyway, the modules works ok, if the BLE, blinky, etc examples are downloaded... working in Segger EM.

    Looking forward to your reply!

    Best.

  • Hi,

    All GPIOs are the same in principle, though as mentioned there are some exceptions (some needs to be enabled, and some are only for low frequencies). You can see the details of that in the pin assignments table. However, not all pins are GPIOs. For instance, the F3 pin on the module is the DP pin, which is not a GPIO. It can only be used with USB. The F7 pin however is a normal GPIO (P0.06), and you configure it just as any other GPIO pin. If it does not work, it is probably because of some external circuitry, though I cannot see anything relevant from the schematics.

  • Hi,

    indeed, the F3 cannot be used as a GPIO including the F7 in this case it may be the UART that is used...

    Anyway, I have moved to the explicit GPIOs, namely P0.14 and P0.20 . Here the led can be blinked, however, the TWI still does not want to connect to the sensor , the troubling fact is that the same code and sensor work seemlesly on the nrf52dk :/

    Best.

  • Hello all,

    after checking all the connection again, the solution has been discovered. The PUP that were used are apparently not necessary! So the wonder is, are the PUP already used on the GPIO? How to check that? Looking at the code there is nothing that would resemble that ...

    Best.

Reply Children
Related