hi friends i have doubt on i/o pins configuration of 8051.when i am writing embedded c program for selecting the single bit code sbit led=P1^0; like that for selecting all port0 pin means sfr led=0x80;... but my doubt on first im selecting all port pin using sfr then how i selecting particular pin example P0.1 form that sfr port for read and write.....
"i am writing embedded c"
Important background:
Specifically, you are writing Keil C51; the standard 'C' language has no way to directly access individual bits - so this is an entirely proprietary extension to the language. http://www.keil.com/support/man/docs/c51/c51_extensions.htm
It is specific to Keil C51, and not general to any other compilers - not even (necessarily) to other Keil compilers.
Back to the question:
In the 8051 architecture, bits don't just exist in isolation - they have to be part of a byte in either bit-addressable RAM or in a bit-addressable SFR. That's why you first have to define a variable in either bit-addressable RAM or in a bit-addressable SFR; eg,
unsigned int bdata uint_base; /* Bit-addressable int */ unsigned char bdata uchar_base; /* Bit-addressable char */ sfr P0 = 0x80; /* Port-0, SFR address 80h */ sbit my_int_bit0 = uint_base ^ 0; /* bit 0 of uint_base */ sbit my_int_bit15 = uint_base ^ 15; /* bit 15 of uint_base */ sbit my_char_bit0 = uchar_base ^ 0; /* bit 0 of uchar_base */ sbit my_char_bit7 = uchar_base ^ 7; /* bit 7 of uchar_base */ sbit my_sfr_bit0 = P0 ^ 0; /* bit 0 of the P0 SFR */ sbit my_sfr_bit7 = P0 ^ 7; /* bit 7 of the P0 SFR */
It's all in the Keil Manuals: http://www.keil.com/support/man/docs/c51/c51_le_bitaddrobj.htm
http://www.keil.com/support/man/docs/c51/c51_le_sfrs.htm http://www.keil.com/support/man/docs/c51/c51_le_sfr.htm
Keil examples: http://www.keil.com/download/list/c51.htm Keil Application Notes: http://www.keil.com/appnotes/list/c51.htm
For general information on the 8051 architecture, see: http://www.keil.com/books/8051books.asp http://www.8052.com/tutorial
I meant, "In the Keil C51 implementation, bits don't just exist in isolation"
But even that isn't quite true: the sbit keyword does allow you to specify a bit address without first defining a variable - See: http://www.keil.com/support/man/docs/c51/c51_le_sbit.htm - Variants 2 & 3