Debugging Skill and Pull Down Resistor
Hi,
I have a quick question about the pull-up and the pull-down resistor. For example, I want to use the switch (S1) to control the output of the GPIO pin (PA0), and read this output to turn on/off another LED. When I set the GPIO pin,
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOA, &GPIO_InitStructure);I can make the program work as I expected when I set it to be pull-down or NOPULL (float?). After some searching online, my understanding is that when I set the pin to have a pull-down resistor, there is a pull-down resistor shown in the figure, the PA0 is 0 when S1 is open and is 1 when S1 is closed. Is my understanding correct?
Also, when I use the debugmode in Keil, there are a register block and a disassembly block shown on the screen but I do not know how to use them. For example, I want to see the output of the pin PA0 in each step (when I press S1 or release S1), which part shall I look at?
Another minor question is that what will happen if I mistakenly set the mode to be pull-up. Will the output always be HIGH, or somewhere randomly between HIGH and HIGH/2 (since I guess pull-up resistor and R64 divide the voltage by half)?
Thank you for your help!
#keil #pull-down #stm-32f407 #pull-up #debug #gpio Note: this post was migrated and contained many threaded conversations, some content may be missing.