Read and Write to a GPIO

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

cross mob
Anonymous
Not applicable

 What is the correct way to read and write from a particular port pin without affecting the other pins of the same port?

0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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. 

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Use shadow registers -

   

 

   

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

   

http://www.planetpsoc.com/psoc1-articles-digital/13-basics-of-psoc-gpio.html?start=5
 

   

 

   

Useful GPIO ap note attached.

   

 

   

Regards, Dana.

0 Likes
ArvindK_86
Employee
Employee
10 sign-ins 5 sign-ins 10 solutions authored

Here's the link to the appnote page - AN2094 - Getting Started with GPIO

   

 

   

 

   

Dana,

   

 

   

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! 

   

 

   

Regards,

   

Arvind

0 Likes
Rolf_Nooteboom
Level 5
Level 5
10 sign-ins 5 solutions authored First solution authored

 Was the initial question from a Cypress employee??

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Obviously, yes. Maybe that was a test or some fresh meat.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

this might help in GPIO

   

http://www.cypress.com/?rID=39496

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.....

   

Regards, Dana.
 

0 Likes