Lab 20. Detecting GPIO state
Project 01bsp_gpio_in is a standalone project for the AIOT Play board. We will detect the state of a GPIO pin by configuring it as an input.
Make 01bsp_gpio_in the active project
In the source code, activate the 01bsp_gpio_in project.
Examine the source code
Open the 01bsp_gpio_in.c file.
Which pin is configured as INPUT in the code?
Connection
Connect the nRF52840-DK to the AIOT Play
Put batteries in the AIOT Play
Plug in the nRF52840-DK
Switch the nRF52840-DK on
In Segger, select “Build and Debug” which will compile the project and load the resulting binary on the AIOT Play
Set a breakpoint in the code by clicking on a source code line number
Take a jumper cable and connect the pin you identified with GND
Now, connect the jumper to
3.6 V
Where did you set the breakpoint to see the changes on the GPIO?
What is the level of the GPIO when there is no jumper cable connected?
Crash course
Pull-up and pull-down GPIO modes
Once we understand pull-up and pull-down GPIO modes, let’s make some changes to the code. Let’s configure the GPIO pin first in pull-down mode, and redo the test with the breakpoint. Let’s do the same in pull-up mode.
What did you change to configure your GPIO pin as pull-down? What did you change to configure your GPIO pin as pull-up?
What behavior do you observe when debugging with a breakpoint?