Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 1 > Modifying Drive Mode From C Code

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



Modifying Drive Mode From C Code
Moderator:
ARVI

Post Reply
Follow this topic



Modifying Drive Mode From C Code

rnixon posted on 13 Apr 2011 6:24 AM PST
Member
4 Forum Posts

Is it possible to change the drive mode of a certain PIN at runtime for C Code.

In my application I have defined P3[7] as "Pull Up" in the IDE, I want to change it to "Pull Down" at runtime.

My best guess how to do this is code like this  ...

PRT3DM1 |= 0x80
PRT3DM0 |= 0x80

In other examples I've seen stuff about 'disconnect from global bus', would I need to do this as well?




Re: Modifying Drive Mode From C Code

graa posted on 13 Apr 2011 09:38 AM PST
Cypress Employee
275 Forum Posts

Yes. You are correct.

To make P3[7] pull up, you would use the following code.

PRT3DM0 |= 0x80;
PRT3DM1 |= 0x80;
PRT3DM2 &= ~0x80;

To make it pull down:

PRT3DM0 &= ~0x80;
PRT3DM1 &= ~0x80;
PRT3DM2 &= ~0x80;

The write to PRT3DM2 is redundant if you do not change to any other drive mode that may set the DM2 bit.

Regarding the connecting to Global bus, if the pin has to connect to a digital block through the Global In or Global Out nets, the the bit in the PRTxGS register has to be set.  If you are controlling the pin through the PRTxDR register, then the pin has to be disconnected from the global bus by clearing the PRTxGS bit.

Best Regards,
Ganesh
The PSoC Hacker
 






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: 01/01/20