This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pull down resistor

im using lpc1768
i connected button to P0.5, led to P0.4
initially the button pin should go low, if i press the button P0.5 should get high
but the pin is always high
i checked the pin with multimeter without connecting button it is giving 3.3v
here is my code

#include "lpc17xx.h"
#define led (1<<4);
#define button (1<<5)
uint32_t buttonstate;
int main(void)
{
        SystemInit();
        LPC_GPIO0->FIODIR |= led;  //output
        LPC_GPIO0->FIODIR &= ~(button); // input
        LPC_PINCON->PINSEL0 &=~((1<<9)|(1<<8));      //led pin gpio function
        LPC_PINCON->PINSEL0 &=~((1<<11)|(1<<10)); //button pin gpio function
        LPC_PINCON->PINMODE0 |= ((1<<11)|(1<<10)); //button pin pulldown mode function
        while(1)
        {
                buttonstate = ((LPC_GPIO0->FIOPIN & button)>> 5);
                if(buttonstate)
                {
                        LPC_GPIO0->FIOSET |= led;
                }
                else
                {
                        LPC_GPIO0->FIOCLR |=led;
                }
        }
}

Parents
  • Sounds strange - the weak pull-up would normally manage to make all pins reach 3V3 unless external hardware loads the pins.

    In your case, it sounds like the other pins are floating. But the default value of the PINMODE registers should be that the pins should have weak pull-up enabled.

Reply
  • Sounds strange - the weak pull-up would normally manage to make all pins reach 3V3 unless external hardware loads the pins.

    In your case, it sounds like the other pins are floating. But the default value of the PINMODE registers should be that the pins should have weak pull-up enabled.

Children
No data