 | Discussion Forum |  |
|
|
Declaring array of pinsNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Shyam Naren Posted 5-Oct-2009 20:28 GMT Toolset C51 |  Declaring array of pins Shyam Naren How to declare an array of pins? I tried the following approach. sbit pins[2]={0x80,0x81} I need to declare them in an array because I have to make multiple changes to pins in my project. My code will become very bulky if I use one variable for one pin. Is there a way out? | | Read-Only Author Per Westermark Posted 5-Oct-2009 20:43 GMT Toolset C51 |  RE: Declaring array of pins Per Westermark Your processor can't index bit variables. Making multiple changes to pins at the same time can sometimes be done by using and/or operations on the container byte for a 8-pin port. | | Read-Only Author Andy Neil Posted 5-Oct-2009 21:13 GMT Toolset C51 |  RE: Your processor can't index bit variables. Andy Neil Your processor also can't index SFRs - which means that you also can't have arrays of SFRs, or pointers to SFRs. You can access the individual pins of a port as sbits; You can also access the complete 8-bit port SFR as a byte; but only direct accesses - no indexing/arrays. For details of the capabilities (and limitations) of the 8051 architecture, you need to study the so-called "bible" for the 8051: See: http://www.8052.com/faqs/120112 for the links to the so-called "bible" for the 8051. See also: http://www.8052.com/tutorial for basic 8051 architecture tutorials. | | Read-Only Author Neil Kurzman Posted 6-Oct-2009 21:18 GMT Toolset C51 |  RE: Declaring array of pins Neil Kurzman Or you can make a function that does what you need and call that over and over. | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|