What is the correct way to read and write from a particular port pin without affecting the other pins of the same port?
Reading the port data register (PRTxDR) and masking off the unwanted bits is the way for reading.
To write to a port, use a global byte-variable ( Shadow-register) and set the appropiate bit(s) as wanted, then copy the byte to the PRTxDR register or use a Shadow-register usermodule.
To be free of handling all that yourself, use the usermodule LED and set its port and pin accordingly. Now you may use the LED_On(), LED_Off() etc functions to control the state of the pin. The usermodule uses a shadow-register internally.
Use shadow registers -
Useful GPIO ap note attached.
Here's the link to the appnote page - AN2094 - Getting Started with GPIO
I would suggest referencing to appnotes via its download page rather than attaching the file here.
The appnote's homepage will always be up to date with the latest version of the document and the example projects with the latest version of PSoC Designer.
Even though attaching the pdf here will be a quicker option to download it, members visiting the post in future might miss out on updated content.
On another note, I really appreciate your awesome work in helping out our community. I wish I could learn your secret art of providing references for anything and everything!
Was the initial question from a Cypress employee??
Obviously, yes. Maybe that was a test or some fresh meat.
this might help in GPIO
To post or not post, that is the question !
The criticism very appropriate, links vs actual content, especially considering the discipline
few have attempted before, keeping references updated, my hats off to Cypress on this.
A small story, as a student in the early 70's I wrote a letter to Motorola, told them I was a
student, and asked them for a copy of every ap note they had ever published. 1972 I think.
2 weeks later, 3 boxes arrived, I still have them today. I scanned every one, and read in full
many. Truly great knowledge base we are all creating, like Mot did and does. English not
so good. So best in class critical review how progress is made, which after all, is the primary
goal of any profession.
References, the tragedy of this forum, and www.psocdeveloper.com, is there is not a reference
library where we can upload some of the foundations to our profession. Agilent (HP) has so many
overall best in class papers, notes, briefs, and disapperaing because the libhrarians not always fully
engaged.....While our physical libraries decline, our responsibility
to make sure the great stuff does not decay ? Tek, Phillips, Nicolet, so many WW sources, no longer linked
and stored, let alone converted from scans to searchable docs.....