Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ports

Status
Not open for further replies.

nbalderaz

Programmer
Sep 25, 2005
1
US
Hello

Can somebody tell me how to set only specific pins in a port to be output. I dont want to use all of them just specific ones. I have found code to make all the pins output:

STA DDRA ;Make Port A all outputs

but i just want certain pins to be output
 
What processor are you using?

With most processors, the data direction register will set a bit as output with the corresponding bit the DDR low (say) and as an input with the bit high (say).

So if the DDR has 8 bits and you wanted bit 2 as an output and the rest as inputs you would write 11111011 to the DDR.

If you wanted bit 1 and bit 6 as outputs then you'd write 10111101 to the DDR and so on.

In other words, it all depends on the bit pattern that you write to the DDR.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top