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

GPIO configuration

hi, I am working nrf52832. I am making configuration file for nrf52.so I want to used Led3 set as high.

#define LED3  ((GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos)     | \
               (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)    | \
               (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos));

sense_high is used as high signal i.e. this pin set to high or not?

or if this pin high then we can used.

actually am not understand the meaning of that signal.please reply me as early as possible. thanks

  • Hello,

    this pin set to high or not?

    It is not. You are only creating a preprocessor define with the pin configuration - you are not actually configuring anything.
    Furthermore, I am not sure I understand the configuration you are trying to achieve - you are setting the pin as an output that you would like to be high, but at the same time you want to sense when it is high?

    Which SDK are you using?
    If you would like to set a pin high, you may use the GPIO HAL API directly - using nrf_gpio_cfg_output and nrf_gpio_pin_set to first configure it as a simple output before setting it to high.
    This functionality is demonstrated in the Blinky example. For a little more advanced GPIO usage, please see the pin change interrupt example.

    Please do not hesitate to let me know if anything still should be unclear, or if you have any other questions.

    Best regards,
    Karl 

  • thanks for response, actually i am not understand properly. Can explain me with any example?

    how to set that as high or positive pin?

  • No problem at all, I am happy to help.

    Do you have a nRF52 Development kit, or are you working on a custom board?
    If you do have a development kit, please download the latest nRF5 SDK.
    There, you may see examples of how you can program your device to achieve different functionality.
    For example, I would recommend taking a look at the code for the two examples I referenced in my previous comment.

    You may also use the GPIO HAL API directly, as mentioned. If you are going to do that, you can do it as described; by first configuring the pin as an output, and then using the gpio_pin_set function to set it to high.

    Could you specify for me what this high pin will be used for? Be advised that it is not recommended to power another device or sensor through the GPIO pins.

    Best regards,
    Karl

Related