Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > Change pin direction on CY8CKIT-001

Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Change pin direction on CY8CKIT-001

Summary: 7808 Views, 3 Replies, Latest reply by Swys on 24 Nov 2010 11:14 PM PST

Verified Answers: 0

Post Reply


Swys posted on 22 Nov 2010 6:23 AM PST
Member
5 Forum Posts

 Hi all,

 

I am a complete noob when it comes to PSoC.

How can I dynamically set a GPIO pin as input or output, as and when needed (as in the 1-wire protocol) on the PSoC 5?

 

In the 1-wire protocol, I have to pull the line low for a certain amount of time, and then "release" the line by setting the pin as an input, and then read the value on the line.

 

Can anyone please help me with this?



 

Panson posted on 22 Nov 2010 01:46 PM PST
Top Contributor
25 Forum Posts

You can change the direction of a port pin by setting the PRTxDM registers. Bidirection mode of a pin is probably your choice.


Panson posted on 22 Nov 2010 07:56 PM PST
Top Contributor
25 Forum Posts

I just made a change in my code to dynamically change a port pin from connecting a digital PSoC block output to CPU data register (PRTxDR). This is simply by setting the bypass bit of the associated pin to zero.

 

PRT4GS &= 0xAF;                            // clear P4.4 and P4.6 bypass bit
PRT4DR |= 0x50;                            // P4.4 and P4.6 = 1


Swys posted on 24 Nov 2010 11:14 PM PST
Member
5 Forum Posts

 Thanks for your replies.

 

I tried changing the drive mode, but it did not work. But you guys did point me in the right direction...

 

I found the bidirectional mode enable bit. I enabled bidirectional mode and it worked! The PSoC now releases the pin when I enable the bidirectional mode so that I can read the input value. To enable output mode again, I just disable bidirectional mode.

 

Even though this works for me, is this the correct way of handling this?



 

Post Reply






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 06/15/20