- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for the responses. Problem solved.