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

how to enable gpio pin after button events

Hello

I wrote the program by referring the some examples after compiling the program GPIO pin becomes high immediately (3.3V ) bu my aim is to make the GPIO pin as output only after the button press so anyone suggest me how to make the function like that please refer my example and help me if possible because am a new learner so all ideas and helps will eb greatly appreciated

thank you

Parents
  • Hi.

    Since you did not write which pins you are talking about, i assume (from reading the code) that you mean pin 6 and 7.

    Inside init_gpio(); you do the following:

        nrf_gpio_range_cfg_input(BUTTON_1, BUTTON_2, NRF_GPIO_PIN_PULLUP);//
        nrf_gpio_range_cfg_output(0, 7); 
    	nrf_gpio_pin_set(6); //clear the LED                              
        nrf_gpio_pin_set(7);//clear the LED
    

    The last two lines will set pin 6 and 7 high. If you comment out these two lines, and put them inside your button handler instead, they will stay low until the button is pressed.

    case BUTTON_1:		 
         app_timer_start(m_timer_id, MS_TO_TICKS(BUTTON_PRESS_TIME_MS), NULL); 
         nrf_gpio_pin_set(6); //clear the LED                              
         nrf_gpio_pin_set(7);//clear the LED
         break;
    
  • thanks for your reply i managed to do can you tell me i want to set the pin 6 and pin 7 in high drive mode i am using this function based on some other post

    NRF_GPIO->PIN_CNF[6] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos);

    does this will make the pin 6 drive in 5mA current mode ? how can i check this pin 6 is providing 5mA? can you give me some information about his HOH1and HOD1 because it is not clear for me

Reply
  • thanks for your reply i managed to do can you tell me i want to set the pin 6 and pin 7 in high drive mode i am using this function based on some other post

    NRF_GPIO->PIN_CNF[6] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos);

    does this will make the pin 6 drive in 5mA current mode ? how can i check this pin 6 is providing 5mA? can you give me some information about his HOH1and HOD1 because it is not clear for me

Children
No Data
Related