You are here

Reading From an Output Pin | Cypress Semiconductor

Reading From an Output Pin

Summary: 10 Replies, Latest post by Bob Marlowe on 07 Sep 2016 10:57 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
user_1815019's picture
User
14 posts

In the hardware design (PSoC Creator 3.3, PSoC 4 Prototyping Kit) I use some digital components with external inputs to decide how to set a digital output with hardware connection outside the PSoC. This works quite good. Now I want to read this output and use the value in the c-program to display additional stuff on the LCD-Display. But I have no luck in getting a value from the output-pin.

I start with defining a variable...

int CutOffVariable = 1

and later I'm polling the digital output "Cut_Off" with...

CutOffVariable = Cut_Off_Read();

but the variable doesn't change although I measure that the the hardware pin has changed it's status.

I tried also with ...

CutOffVariable = Cut_Off_ReadDataReg()

but I had no luck,  probably don't understand the format of the returned value.

Any ideas how to solve this problem?
Cheers
Thomas

user_1377889's picture
User
10419 posts

Can you please post your complete project or a reduced excerpt that shows the error, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

 

Bob

 

user_242978793's picture
User
1351 posts

Here is the manual on IO pins.

user_242978793's picture
User
1351 posts

Here is a small program.

user_1815019's picture
User
14 posts

OK here's the project.
As I said, the output-pin "Cut-Off" changes and triggers an external electronic device. But how can I read the state of the "Cut-Off"-pin in the c-code? Line 103 doesn't change the value of the variable.

Thanks
Thomas

user_1377889's picture
User
10419 posts

Quite easy: You just have to enable the "Digital Input" in the Cut_Off pin configuration.

 

Happy coding

Bob

user_1815019's picture
User
14 posts

Sounds easy, so I enabled the digital input of the Cut_Off pin, but when I code ...

CutOffVariable = Cut_Off_Read();

... the CutOffVariable is always 0, although the Cut_Off pin is connected to a LED that is changing its's status???

user_1377889's picture
User
10419 posts

What digital value do you expect when an LED is connected to the pin? Even with a removed LED there will be no correct Hi-level.

Way out(s):

  • Measure the voltage and use a comparator at the input.
  • Use an ADC
  • Remove the LED or use another pin for it. (Set the drive mode to resistive pull up or pull down)

 

Bob

user_1815019's picture
User
14 posts

Thanks, using a second pin parallel to the Cut_Off pin helped.

The Cut_Off pin is in open drain drive mode. I did expect to read  a 0 or 1 from the digital pin but only got 0 in any case.

Thomas

user_1815019's picture
User
14 posts

Everything is working fine here :-)
Just to be sure I understand the principle correct: When I read out a pin with a component-API, I don't get the signal that is driving the pin (for instance a signal coming from a Flip-Flop to the pin) but the signal that is actually present at the physical pin?

Thanks a lot!
Thomas

user_1377889's picture
User
10419 posts

You are quite right with your estimation.

When you want to see which value you set the pin to, use Pin_ReadDataReg (). I do not know whether this API works when the pin was set by an internal signal (as your mentioned flip-flop), but I think you cannot read back the signal value.

 

Bob

Log in to post new comments.