Hi all,
I am stuck with a simple but weird issue. It's driving me crazy for the last few hours. I am using a PCA10056 DK.
I am somehow unable to do a simple digital pin read correctly with nrf_gpio_pin_read when I configure the pin to be pulled up or pulled down.
Here is what I did,
1. I configure P0.17 as input with nrf_gpio_cfg_input(CUSTOM_BUTTON, NRF_GPIO_PIN_PULLUP);
2. I read the pin with nrf_gpio_pin_read and print the values on the debug screen.
3. The read value seem to be stuck at 1 even when I physically connect the pin 17 to ground intermittently with a jumper wire.(Simulating a push button)
This value seems to be stuck at 0 when I configure the input pin with NRF_GPIO_PIN_PULLDOWN. No change even if I physically short the pin to VDD. But the pin seems to be working fine if I configure it with NRF_GPIO_PIN_NOPULL. I am able to see the values toggle when I connect to VDD or GND accordingly.
The problem seems to be occurring only when configured in pullup or pulldown mode.
I am attaching the main.c code snippet. (It will compile if its put in SDK15.3, ble_app_template code main.c section)
#define CUSTOM_BUTTON 17 uint8_t button_value = 0; int main(void) { bool erase_bonds; // Initialize. log_init(); timers_init(); buttons_leds_init(&erase_bonds); power_management_init(); ble_stack_init(); gap_params_init(); gatt_init(); advertising_init(); services_init(); conn_params_init(); peer_manager_init(); // Start execution. NRF_LOG_INFO("Template example started."); application_timers_start(); advertising_start(erase_bonds); nrf_gpio_cfg_input(CUSTOM_BUTTON, NRF_GPIO_PIN_PULLUP); // NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_NOPULL // Enter main loop. for (;;) { button_value = 0; idle_state_handle(); nrf_delay_ms(1000); button_value = nrf_gpio_pin_read(CUSTOM_BUTTON); printf("Button Reading: %d\r\n", button_value); } }
Can someone help me out on pointing the issue here? It seems so simple and I might have overlooked something but I cant find the issue here.
I tried with a different PCA10056 DK too so it's not a hardware issue.
Thanking you in advance.
Edit: When I repeated the experiment few hours later, its seems to be misbehaving at NRF_GPIO_PIN_NOPULL mode too. (No change in the reading)