Initial Drive State vs. Drive Mode for Resistive Pull Up/Pull Down

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi all, I'm new to the cypress community--so my apologies if this is posted in the wrong place.

I'm making a simple project in my BLE Pioneer Kit where an LED changes color when you press SW2. I have configured SW2 as an input and two LEDs as outputs. I am using the following code to determine when the button is pressed:

int push_flag = 0;

for(;;)

{

        while (Cy_GPIO_Read(PUSH_PORT, PUSH_NUM) == 1) { // If you push the button

            push_flag = 1;

        }

//Code continues

}

What I'm confused about is, regardless of whether or not my input is configured as a Resistive Pull Up or a Resistive Pull Down and regardless of whether or not I put a "0" or a "1" in the while loop comparison, my code works the same so long as the Initial Drive State of the pin is a 1.

In other words, any combination of drive mode and while loop comparison is successful (4 possible combinations) so long as the Initial Drive State is 1.

Clearly, I'm not understanding something about what initial drive state means, so any suggestions are much appreciated!

0 Likes
1 Solution

Yes the pictures on that website are correct.

Here is a screenshot of that section of the schematic... (notice that R145, R148 and R149 are NO LOAD ... meaning that they are not on the board)... so basically the switch is connected to P04 on one side... and shorted to ground through a 0 ohm resistor on the other.

Screen Shot 2018-05-03 at 6.53.33 AM.png

As to the initial drive state... as the pin is an INPUT the initial drive state doesnt do anything.. that value is only when the GPIO is configured as an output (or an input/output)

View solution in original post

0 Likes
4 Replies
AlanH_86
Employee
Employee
100 replies posted 50 replies posted 25 solutions authored

The switch on that board has an active low switch (meaning it shorts it to ground).

Moreover that node floats... so you need to use the resistive pull up in the I/O buffer to pull it high.

And... because it is active low... when you Read the pin... low means they are pressing the button.


Alan

0 Likes
Anonymous
Not applicable

Hi Alan,

Thank you for your reply. To clarify one thing, by saying that the switch on the board is an active low switch, are you saying that it is automatically suited for using a Resistive Pull up (I am basing my understanding off of this webpage)? That would make sense given the diagram on the back of the PCB.

In that case, why does my code also work properly when I configure it as a Resistive Pull Down?

Many thanks again,

Maddie

0 Likes

Yes the pictures on that website are correct.

Here is a screenshot of that section of the schematic... (notice that R145, R148 and R149 are NO LOAD ... meaning that they are not on the board)... so basically the switch is connected to P04 on one side... and shorted to ground through a 0 ohm resistor on the other.

Screen Shot 2018-05-03 at 6.53.33 AM.png

As to the initial drive state... as the pin is an INPUT the initial drive state doesnt do anything.. that value is only when the GPIO is configured as an output (or an input/output)

0 Likes
Anonymous
Not applicable

My first update would be that it's now apparent to me why the value in my while loop comparison can be either a 0 or a 1 (because it's a while loop, it will break whenever the value changes--which is initiated by pressing the switch--, regardless of what that value is).

This just leaves the question of why Resistive Pull Down is successful with an Initial Drive state of 1, which to my understanding, is counter to the PSoC GPIO Pin documentation's suggested Initial Drive state of 0 for the pull down drive mode.

0 Likes