I am using AT89C52 and I need to program such that I can read the data on PORT Pins in a specific pattern as described below: P(x,y) where x should be port number and y should be pin number of the port to give me PX_Y ex. P(0,5) == P0_5 How can I do this? Can anyone help me in this? Please mail me the solution on punit.ganshani@gmail.com
"ex. P(0,5) == P0_5" You can easily do that at compile-time with a #define macro - see any 'C' textbook. You can't do it directly at run-time, since 8051 ports are not indirectly addressable (none of the SFRs is). You'd have to do something like:
bit read_port( U8 port_num, U8 bit_num ) { switch( port_num ) { case 0: return P0 & (1<<bit_num); case 1: return p1 & (1<<bit_num); < i>etc...