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

GPIO pullups and direction

If I write a zero to the output register, and enable the pullup on the same pin, can I switch between driven low output and input with pullup simply by settting/clearing the DIR bit? Will the pullup still be in circuit when the output is enabled? I have studied the datasheet and the associated schematic, but this is still not clear to me.

Parents
  • I have tried the both ,

    NRF_GPIO->DIRSET |= (1UL << LED_1);
    NRF_GPIO->PIN_CNF[LED_1] |=  GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos;	
    
    NRF_GPIO->DIRSET &= ~(1UL << LED_1);
    

    NRF_GPIO->DIRSET &= ~(1UL << LED_1);
    NRF_GPIO->PIN_CNF[LED_1] |=  GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos;	
    
    NRF_GPIO->DIRSET |= (1UL << LED_1);
    while(1);
    

    and the pullup wasn't there. So i am concluding that it will be reset to no_pull everytime we change pin direction

Reply
  • I have tried the both ,

    NRF_GPIO->DIRSET |= (1UL << LED_1);
    NRF_GPIO->PIN_CNF[LED_1] |=  GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos;	
    
    NRF_GPIO->DIRSET &= ~(1UL << LED_1);
    

    NRF_GPIO->DIRSET &= ~(1UL << LED_1);
    NRF_GPIO->PIN_CNF[LED_1] |=  GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos;	
    
    NRF_GPIO->DIRSET |= (1UL << LED_1);
    while(1);
    

    and the pullup wasn't there. So i am concluding that it will be reset to no_pull everytime we change pin direction

Children
Related