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

pin set issue when direction as output pin

hi

I need to set a pin high when i make a connection to the device .so i set to output direction in main.c file.i have include gpio.h and nrf_delay.h file in main file

 nrf_gpio_pin_dir_set(29,NRF_GPIO_PIN_DIR_OUTPUT); //red led

nrf_delay_ms(100);

then i set the pin in ble_evt_handler as


case BLE_GAP_EVT_DISCONNECTED:
nrf_gpio_pin_clear(29);
SEGGER_RTT_printf(0,"Disconnected\n");

break;

case BLE_GAP_EVT_CONNECTED:
nrf_gpio_pin_set(29);
SEGGER_RTT_printf(0,"Connected..\n");
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;

though i have set pin ,this pin gets cleared when i connect device using nRF connect (i.e exactly reverse action happens).i have checked that assiging pin as output sets high on this pin 

where could be the problem?

Parents
  • What are you using  to measure the pin being high or low? I see the word "LED" in the code, if you're using one of the Nordic boards, their LEDs come ON when the pin is low and go OFF when it's high. 

Reply
  • What are you using  to measure the pin being high or low? I see the word "LED" in the code, if you're using one of the Nordic boards, their LEDs come ON when the pin is low and go OFF when it's high. 

Children
  • i am checking LED status when i provide logic high n logic low.

    By writting only this  nrf_gpio_pin_dir_set(29,NRF_GPIO_PIN_DIR_OUTPUT); 

    pin no.29 gets set LED connected to pin 29

  • and how is the LED wired? 

  • i am using RGB led,amoung these i am using pin 29 to which red LED connected 


  • so there you go - with that wiring the LED will come ON when the pin is LOW and goes OFF when the pin is HIGH. So there's nothing wrong here. 

  • just by giving only direction as output this LED becomes ON.I didnot set or clear