Detecting voltage with the PSoC

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

cross mob
Anonymous
Not applicable

Hi All,

   

This should be a very basic question, so forgive me. I'm trying to detect a voltage on a PSoC pin. It's either going to be 3V or 0V. The pin I am using is currently P0[0] and I have its drive set as Pull Down. I initialize the PRT0DR bit to 0, but I never read a high value when the voltage is 3V. Is there something that I am doing wrong?

   

Essentially I want the PSoC to read a high value when a voltage is applied and a low value when the pin is floating.

0 Likes
4 Replies
MR_41
Employee
Employee
First like received

How are you reading the pin?  Are you using the PRT0DR register?  Check out the below blog posts that may be of help.

PSoC GPIO Demystified - Part 1
PSoC GPIO Demystified - Part 2

Best Regards,
Ganesh
The PSoC Hacker

0 Likes
Anonymous
Not applicable

Thank you for responding!

   

 

   

Yes, I am trying to read the bit on PRT0DR. I am essentially doing this:

   

 

   

if (PRT0DR & X)

   

{

   

       trueFlag = 1;

   

}

   

else

   

{

   

      trueFlag = 0;

   

}

0 Likes
Anonymous
Not applicable

Update -

   

I switched the Selected mode to High Z instead of Pull Down and now it works! Thank you for the help!

0 Likes
MR_41
Employee
Employee
First like received

You are most welcome!! Glad to hear that you found the solution and got it working.

   

 

   

Best Regards,

   

Ganesh

   

The PSoC Hacker

0 Likes