You are here

roblems with port configured as input | Cypress Semiconductor

roblems with port configured as input

Summary: 3 Replies, Latest post by kiiid on 07 Jun 2010 04:20 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
kiiid's picture
22 posts

I am trying to do something with an Encore V MCU (7C64343). The problem I am facing has been described many times yet I have been unable to make it work for me at this stage:
On port 1 I have a few digital inputs and one output controlled by an interrupt function.
My problem is that I can never read the actual status of the inputs, they are always 0.
What I am doing is this:

The relevant bits P1.2, P1.3 and P1.4 are configured as StdCPUInput and drive Analog High Z in the PD

unsigned char P1;

and then in the interrupt function (executed around 100 times per second):

P1=PRT1DR; // supposedly reads the actual input states
P1^=0x20; // swinging the output pin
PRT1DR=P1; // update the output

Everywhere else in the code I only use P1 as read from the code above.
Where is my problem here?



user_11685479's picture
41 posts

If you are using P1 as a shadow register, then you should not be updating it with the PRT1DR value.  You should only write values that you need to reflect on your output pins and then update the PRT1DR with P1 value.

Check out the below Blog article that explains the concept of shadow register.

PSoC 1 GPIO Demystified - Part 2

Best Regards, Ganesh

kly's picture
Cypress Employee
13 posts

"Analog hi Z" is not the correct drive state for digital inputs. In order to be digital inputs, they need to be configured as "hi Z". "analog hi Z" drive turns off the digital input schmitt trigger.

kiiid's picture
22 posts

Thank you both for the responses. Problem solved.


Log in to post new comments.