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

External input & output on nRF52840

Hello! I would like to use a predefined example from the nRF SDK and instead of the board's button, to use an external stimulus (let's say, an external button). Similarly, instead of turning on the board's LED, I want to set high a GPIO (let's say, external LED).

Now, I read a lot of questions on devzone about this and it's either very complicated or quite trivial. My idea is to just change in the file pca10056.h the line #define LED_1 NRF_GPIO_PIN_MAP (0,13) to #define LED_1 NRF_GPIO_PIN_MAP (0, xx). And similar for the BUTTON_1. My questions are:

1. Is this the only place where I need to do the modifications? It seems like only a mapping problem to me, but I think I might to re-write other files as well.

2. What do the (xx) need to be? (I read about this mapping in nRF52840's specs, @pag. 525, but I am not sure how to interpret that table into actual code). For instance, let's say that I'd like my A8 pin as a digital output (i.e. drive an external LED). Then, do I need to #define LED_1 NRF_GPIO_PIN_MAP (0, 32)? Or is A8 used already as AIN7, which is actually an analog input (see second line)? 

I am a bit confused after reading a lot about this; sorry for the basic question.

  • Hi ! I am trying the idea which you suggested me the previous week, but I cannot achieve turning on one LED when supplying '1' (5V). When I change the LEDS_ACTIVE_STATE to 1, the other LEDs remain on for the whole time, without me specifying that. (i.e I don't modify the rest of the code)

    In order to debug this, I though of trying to understand these functions, like you suggested:

    functions like buttons_handler and leds_buttons_init()

    - but I cannot find them. Could you please tell me in which .c or .h file should I look for them? I also couldn't find this:

    commenting out Toggle LEDs while loop part

    - it should  probably be in main, but I only see one LED toggling, not more:

    #define LEDBUTTON_LED  BSP_BOARD_LED_2 /**< LED to be toggled with the help of the LED Button Service. */

    Could you plase tell me in which source files should I look for the mentioned functions? Thank you!

  • Hi Alexa,

    alexa said:
    When I change the LEDS_ACTIVE_STATE to 1, the other LEDs remain on for the whole time, without me specifying that. (i.e I don't modify the rest of the code)

    How did you add your external LED in the pca10056.h? Could you insert the related part in the pca10056.h?

     

    alexa said:
    but I cannot find them. Could you please tell me in which .c or .h file should I look for them?

     You can take a look at the BSP Example on how to control the LED. 

     

    alexa said:
    Could you plase tell me in which source files should I look for the mentioned functions?

    I think you are looking at the nRF5_SDK\examples\ble_peripheral\ble_app_blinky, but I mean nRF5_SDK\examples\peripheral\blinky.

    -Amanda H.

Related