Changing multiple output pins status at once

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

cross mob
Anonymous
Not applicable

Hallo,

   

I have a very simple question. I'm using a CY8C29466 and I need to change the status of 3 output pins (defined as 'Strong' drive) and named SEL0, SEL1, SEL2. All of them belongs to the same port P2 specifically P2[1], P2[3], P2[5].

   

Is it possible to change the status of all pins at once using the base register of the port? If yes.. how?

   

Since these pins would 'comand' a mux device change them one by one would lead to some unpredictable status on the final demultiplexed output channels.

   

Best Regards,

   

   Michele

0 Likes
8 Replies
Anonymous
Not applicable

Hallo,

   

I forgot to add that P2[0] and P2[4] ports are 'assigned' to other uses (uart in & out).

   

Best Regards,

   

    Michele Santucci

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

If you are trying to change the drive level for the pin answer is not in one

   

write instruction. Register write in TRM.

   

 

   

Same is true if you are trying to change the routing to the pin, you would do

   

it one pin at a time.

   

 

   

0 Likes
Anonymous
Not applicable

 Hallo danadak,

   

I just have to change the state of the pin (it est set it low or high) I have not to change the drive mode neither to change the routing for that pin.

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

See this, and consider using shadow register to handle partial port

   

pin updates -

   

 

   

    

   

          

   

http://www.cypress.com/?rID=2900     AN2094

   

 

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable
        As you turn on a pin with hex example: PRT0DR |= 0x08; I am sure you can turn on more pins at once using the proper hex. I never tried it though. 0x08 points at the 3 pin, but the 4 bit. Say you wrote 0x09 and it would turn on bit 4 and 1, pin 3 and 0 Am I right?   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

That is quite right, Writing to trhe port data register writes simultanously to all 8 pins of the port. Care must be taken since you always write to all 8 pins which sometimes might not be what you desire. That is why Dana suggested to use a shadow register for. It is ment to avoid a read-modify write from a port which may lead to unpredictable or unexpected results.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        I use PRT0DR &=~ 0x08; to turn of a pin. That works fine. When exactly can you get into trouble?   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Exactly with statements like yours . Have a look here     www.cypress.com/

   

 

   

Bob

0 Likes