# Cypress Developer CommunityTM

## OR gate acts as an AND gate

Summary: 5 Replies, Latest post by hli on 10 Nov 2014 04:18 AM PST
User
2 posts

On the PSoC4 Pioneer Kit I've got a simple test gate configured in the following way...

SW1 is P0[4] -----> Resistive Pull Up (Initial state: High)
SW2 is P0[5] -----> Resistive Pull Up (Initial state: High)

LED is P0[3] -----> Strong Drive (Initial state: High)

[My Problem]
Having an OR gate setup I would expect that when I press SW1 or SW2 the LED would turn on. However, this is not the case. Instead what ends up happening is if I press SW1 and SW2, the LED will turn on acting like an AND gate.

[My Question]
- Why is my OR gate acting like an AND gate.
- What am I not understanding in the way my circuit is built
- What am I not understanding in the way PSoC works
- Can someone show me how to make my OR gate act like an OR gate

[Background]
Relitively new to PSoC. Just finished studying Digital Logic at school (We used Quartus w/ Altera's CPLD)

User
9249 posts

Well, the LED on your board is connected active low, so your equation comes to

NOT(A OR B) which turns out to be NOT(A) AND NOT(B). and lo! there is your AND-gate!

Bob

User
7646 posts

Probably not an issue here since you are not driving other logic with the

output of the OR gate, but if you were to use that signal elsewhere

mechanical swithes "bounce". Attached some info on the topic and

how to implement debounce routines. Note PSOC has a HW component,

"deglitch" that can also be used to do this.

Regards, Dana.

Attachments:
User
2551 posts

To put Bobs answer in plain words:

• and OR gate has its output 1 when at least one of the inputs is 1
• since you have pullups on the inputs, they are both 1 in idle state
• so the output is one by default (and since the LED only goes on when the output is 0 its off then)
• but pressing just one button still keeps the other one at 1, so the output stays at 1
• only when both buttons are pressed, both inputs go to 0, and the output as well - and the LEDs goes on

You just discovered that an OR gate can be converted into a AND gate just by inverting all inputs and the output :)

(And by that you probably have the information what to change in your circuit...)

User
2 posts

Thank you bob & hli, that was very informative. Also, thanks for sharing the debounce12.zip file danaaknight.

User
2551 posts

Welcome to the wonderful world of PSoC!