You are here

Modifying Drive Mode From C Code | Cypress Semiconductor

Modifying Drive Mode From C Code

Summary: 1 Reply, Latest post by graa on 13 Apr 2011 11:38 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
rnixon's picture
4 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?

graa's picture
Cypress Employee
223 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,
The PSoC Hacker

Log in to post new comments.