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
  • Well we'll have to agree to disagree on that, then. I haven't connected a logic analyser, but I have used a low current LED with a 220R resistor in series, and I am getting a dim glow, consistent with a pullup being enabled.

    Using exactly this code(LED is on P0.17)

       NRF_GPIO->DIRCLR = (1UL << 17);		// Set as ip
        NRF_GPIO->PIN_CNF[17] |= GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos; // Set pullup
    
        SEGGER_RTT_printf(0, "PIN_CNF = %08x\n\r", NRF_GPIO->PIN_CNF[17]);
        nrf_start_timer_ms(2000);	// Set timeout at 2 seconds
    
        	while (NRF_TIMER1->EVENTS_COMPARE[0] == 0)
        	  {
        	  }
    
    
        NRF_GPIO->DIRSET = (1UL << 17);		// Set as op
        SEGGER_RTT_printf(0, "PIN_CNF = %08x\n\r", NRF_GPIO->PIN_CNF[17]);
        nrf_start_timer_ms(2000);	// Set timeout at 2 seconds
    
        	while (NRF_TIMER1->EVENTS_COMPARE[0] == 0)
        	  {
        	  }
    
    
        NRF_GPIO->DIRCLR = (1UL << 17);		// Set as ip
        SEGGER_RTT_printf(0, "PIN_CNF = %08x\n\r", NRF_GPIO->PIN_CNF[17]);
    
        while(1);
    

    John

Reply
  • Well we'll have to agree to disagree on that, then. I haven't connected a logic analyser, but I have used a low current LED with a 220R resistor in series, and I am getting a dim glow, consistent with a pullup being enabled.

    Using exactly this code(LED is on P0.17)

       NRF_GPIO->DIRCLR = (1UL << 17);		// Set as ip
        NRF_GPIO->PIN_CNF[17] |= GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos; // Set pullup
    
        SEGGER_RTT_printf(0, "PIN_CNF = %08x\n\r", NRF_GPIO->PIN_CNF[17]);
        nrf_start_timer_ms(2000);	// Set timeout at 2 seconds
    
        	while (NRF_TIMER1->EVENTS_COMPARE[0] == 0)
        	  {
        	  }
    
    
        NRF_GPIO->DIRSET = (1UL << 17);		// Set as op
        SEGGER_RTT_printf(0, "PIN_CNF = %08x\n\r", NRF_GPIO->PIN_CNF[17]);
        nrf_start_timer_ms(2000);	// Set timeout at 2 seconds
    
        	while (NRF_TIMER1->EVENTS_COMPARE[0] == 0)
        	  {
        	  }
    
    
        NRF_GPIO->DIRCLR = (1UL << 17);		// Set as ip
        SEGGER_RTT_printf(0, "PIN_CNF = %08x\n\r", NRF_GPIO->PIN_CNF[17]);
    
        while(1);
    

    John

Children
No Data
Related