Home arrow Support arrow Forums

Luminary Micro Forums

ringram2077

Expert Boarder

2006/12/23 12:36

How to toggle GPIO pin ?

What is the statement to toggle an output pin ? I know how to set a pin high and set a pin low but don't see how a toggle would work. I have seen where the ~ is used to flip the bit on the port. Is there a trick like that that can be used or must you do it the old fashion way ?? Using LM3S811 EVB.

Thanks

Post edited by: ringram2077, at: 2006/12/24 08:16

login or register to reply

ringram2077

Expert Boarder

2006/12/24 09:51

Re:How to toggle GPIO pin ?

This works and is pretty simple I suppose:

Code:

     if(GPIOPinRead(GPIO_PORTC_BASEStatus_LED))  //toggle led     GPIOPinWrite(GPIO_PORTC_BASEStatus_LED0); //set to zero     else     GPIOPinWrite(GPIO_PORTC_BASEStatus_LEDStatus_LED);//set to one

login or register to reply

orinem

Expert Boarder

2006/12/24 13:57

Re:How to toggle GPIO pin ?

If you want to avoid the if, the following should do the trick:

GPIOPinWrite(GPIO_PORTC_BASE,
Status_LED,
~GPIOPinRead(GPIO_PORTC_BASE, Status_LED));

Orin.

login or register to reply

ringram2077

Expert Boarder

2006/12/24 21:06

Re:How to toggle GPIO pin ?

That's the trick I was looking for !!!!!


Thanks Orin

login or register to reply