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

toggle a pin of nrf52

hi,

I am using nrf 52 DK and  softdevice S132,PCA10040 board . I need to toggle a pin,set a pin,reset a pin .can anyone take this ticket  to a sample code/ code snippet and which packs do i need to install.basically i just want to write a simple code where i want to toggle a pin continously .

  • Hey Kirt, this shouldn't be a problem at all. I do believe this is also a common question on the forum.

    Simply include nrf_gpio.h in your C/C++ source file. This is Nordic's API that will let you interface with board at a high level. You can read more about GPIO here.

    I would define a pin at the top of your code like the following. 

    The NRF_GPIO_PIN_MAP is a simple macro that converts the Pin # printed on the DK to the appropriate map for the board. The cfg_output simply sets the pin as an output instead of an input (no need for internal pull resistors). 

    Then use the nrf_delay_ms function to create your frequency to continuously toggle a pin.

    Hopefully this helps,

    Rishi

  • hi 

    i gone through the step 1,2,6.where can i get nRF5_SDK_14.1.0_04a0bfd

    and i am using nRF52Dk as a debugger/programmer.