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

GPIO Cannot be Programmed

Hi Nordic Experts,

I use nRF52832 for a custom board, I use GPIO P0.17 and P0.18 for controlling NMOS switch, for buzzer and vibration motor, and the frequency is controlled by ADC value. I use SDK 16 for firmware, and programming through nRF52DK serial wire. At first, I can program it just fine, but after reprogramming it for couple of times, these two GPIOs cannot be programmed, but keeps on switching as programmed previously. I suspect that I might have damaged the GPIO pins, but the current drawn should not be too much since they just drive the transistor. Attached are the schematic and code snippet. Thank you.

saadc_init();
nrf_gpio_cfg_output(GPIO_OUTPUT_BUZZER);
nrf_gpio_cfg_output(GPIO_OUTPUT_VIBRATION);

for (;;)
{
    nrf_drv_saadc_sample();
    if (count < abs(saadc_value))
        {
            nrf_gpio_pin_clear(GPIO_OUTPUT_BUZZER);
            nrf_gpio_pin_clear(GPIO_OUTPUT_VIBRATION);
        }
    if (count >= (abs(saadc_value)))
        {
            nrf_gpio_pin_clear(GPIO_OUTPUT_BUZZER);
            nrf_gpio_pin_clear(GPIO_OUTPUT_VIBRATION);
            if (count >= (abs(saadc_value)))
            count = 0;
        }
    if (count >= (abs(saadc_value)*2))
        {
            count = 0;
        }
    count++;
}
 

  • Hi,

    Was it intentional that you only used nrf_gpio_pin_clear and not nrf_gpio_pin_set in the above code?

    Can you test with a basic application without anything else, to make sure nothing else is controlling the pins? For instance something like this:

    #include "nrf_delay.h"
    #include "nrf_gpio.h"
    
    #define GPIO_OUTPUT_BUZZER 17
    #define GPIO_OUTPUT_VIBRATION 18
    
    void main(void)
    {
        nrf_gpio_cfg_output(GPIO_OUTPUT_BUZZER);
        nrf_gpio_cfg_output(GPIO_OUTPUT_VIBRATION);
        
        while(1)
        {
            nrf_gpio_pin_clear(GPIO_OUTPUT_BUZZER);
            nrf_gpio_pin_set(GPIO_OUTPUT_VIBRATION);
            
            nrf_delay_ms(500);
    
            nrf_gpio_pin_clear(GPIO_OUTPUT_BUZZER);
            nrf_gpio_pin_set(GPIO_OUTPUT_VIBRATION);
    }

    Best regards,
    Jørgen

Related