Hello,
Using an Arduino nano 33 ble which contains a nrf52840.
Using arm-none-eabi-gcc version 9.2.1 in debian/linux, uploading using openocd en gdb.
I tested my problem on 2 different boards and 2 different gpio ports. I started with the blinky example and added reading a button.
The button is a switch to ground and when using pullup for the gpio it should work. But it doesn't, always the else-branch is taken!
What am I doing wrong here? Thanks in advance, Sietse
/ Test button press on Arduino nano 33 ble
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#define LED_DL1 NRF_GPIO_PIN_MAP(1,9) // Led pwe
#define LED_DL2 NRF_GPIO_PIN_MAP(0,13) // Led builtin
#define ARDUINO_3_PIN NRF_GPIO_PIN_MAP(1,11) // Digital pin 2
#define BUTTON_2 ARDUINO_3_PIN
int main(void)
{
nrf_gpio_cfg_input(BUTTON_2, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_output(LED_DL1);
nrf_gpio_cfg_output(LED_DL2);
while (true)
{
if (nrf_gpio_pin_read(BUTTON_2)) {
nrf_gpio_pin_toggle(LED_DL2);
nrf_delay_ms(100);
}
else {
nrf_gpio_pin_toggle(LED_DL2);
nrf_delay_ms(500);
}
}
}