cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

 Hello
I am using the psoc UC that I have attached picture of.
My quistion. Can I use P1.1 and P1.0 as analog inputs? Right now I have set them up to be analog inputs only to check if the port is high or not (checking for a button to be pushed). Though it seems that it fails now and then, and I cant find a failure in the code, and worked long time with it. Is it wrong of me to check these ports for high or low using: "if (PRT1DR & pin1{}"?

Select: globalinodd
Drive: high z

Thanks in advance

0 Likes
Reply
1 Reply
Esteemed Contributor

"Normally" you would set up a button input as follows -

   

 

   

   

 

   

This is a button ftom pin to Vdd, if you want button to pull low then

   

change Drive to Pull Up, button connected from pin to Vss.

   

 

   

If you are doing read m,odify writes to a port then you must use shadow

   

registers -

   

 

   

    

   

         

   

http://www.cypress.com/?rID=2900     AN2094 - PSoC® 1 - Getting Started with GPIO

   

https://www.youtube.com/watch?v=tei6q5M3C0g       Shadow Registers

   

http://www.cypress.com/?rID=39497     Shadow Registers

   

 

   

Also for buttons do not forget to debounce them -

   

 

   

www.dropbox.com/s/r8vfqea5fhiuzw1/Debounce.zip

   

 

   

 

   

Regards, Dana.

0 Likes
Reply