# accessing the bit from the header file

Status
Not open for further replies.

#### piyushpandey

##### Member level 4
Hi guys

I have accessed the bits of corresponding registers by the syntax REGISTERbits.bitno and through this syntax I get by default that particular bit to be showed in the MPLABX IDE but when I try to access the VCFG bit of the ADCON0 register I did not get that sort of automatic pop up window showing the list of bits defined in the structure, Instead I get the list of few bits and not all.

I am trying to access the VCFG bit from the ADCON0 register structure defined in the pic16f688 header file in the HiTECH compiler of version 9.83.

The structure code of the particular ADCON0 register is this:

Code:
// Register: ADCON0
volatile unsigned char           ADCON0              @ 0x01F;
// bit and bitfield definitions
#ifndef _LIB_BUILD
volatile union {
struct {
unsigned	GO_nDONE            : 1;
unsigned	CHS                 : 3;
unsigned	                    : 1;
unsigned	VCFG                : 1;
};
struct {
unsigned	: 1;
unsigned	: 1;
unsigned	: 3;
unsigned	: 1;
unsigned	: 1;
unsigned	: 1;
};
struct {
unsigned	: 1;
unsigned	GO                  : 1;
unsigned	CHS0                : 1;
unsigned	CHS1                : 1;
unsigned	CHS2                : 1;
};
struct {
unsigned	: 1;
unsigned	nDONE               : 1;
};
struct {
unsigned	: 1;
unsigned	GO_DONE             : 1;
};
} ADCON0bits @ 0x01F;

Please help me that how can I access the VCFG bit from the ADCON0 register. I am using the MPLAB X IDE in which when I access the bit as ADCON0bits.VCFG than it shows the error.

So please tell me that what this structure is all about and how can I access all the bits define inside it.

Thanks

#### Tahmid

What error does it show?

Is the 16F688 selected? Did you select it from the device selector?

#### piyushpandey

##### Member level 4

yeah tahmid I have selected the pic16f688 in the configuration window. actually the problem is that when I am trying to access the individual bits of the ADCON0 defined in the structure than only few of them are accessible and few of them does not show in the auto completion box in the MPLABX IDE and when you try to access them than it throws an error by marking or underlining it with red.

for example here I am pasting a screenshot of what appears in the actual window and what does not come up in the window.

View attachment 76588

now in this auto completion window the structure elements which are available are accessible without an error, but when I try to access the structure variable which do not appear in the auto completion box than I get the error like this in the form of a red mark :

View attachment 76594

Now please tell me that why this is happening thank you , why I am not able to get the access to all the structure elements present.

Also I want to know if someone can explain that how this structure field is defined and if any material or article or book is available for it than please tell me.

Thanks

Status
Not open for further replies.