bladetooth@verizon.net wrote 2011-12-29 16:37: > But OSCCON is a union, isn?t it? Shouldn?t that mean I can address its > structured bits? Or am I reading this part of the header file wrong? > Yes, you are. OSCCON is an simple "unsigned int". Then there is another definition of OSCCONBITS that is a struct (or rather an union of two structs...). Jan-Erik. > > ? extern volatile unsigned int OSCCON __attribute__((__sfr__)); > > __extension__ typedef struct tagOSCCONBITS { union { struct { unsigned > OSWEN:1; unsigned LPOSCEN:1; unsigned :1; unsigned CF:1; unsigned :1; > unsigned LOCK:1; unsigned IOLOCK:1; unsigned CLKLOCK:1; unsigned > NOSC:3; unsigned :1; unsigned COSC:3; }; struct { unsigned :8; unsigned > NOSC0:1; unsigned NOSC1:1; unsigned NOSC2:1; unsigned :1; unsigned > COSC0:1; unsigned COSC1:1; unsigned COSC2:1; }; }; } OSCCONBITS; ? > > > > > Ryan Pettigrew > > On 12/28/11, piclist-request@mit.edu wrote: > >> but can?t seem to do simple things like ?OSCCON.OSWEN =3D true;? > > It is always a good idea to look at the appropriate header file. > > In most cases, what you want is something like > > OSCCONbits.OSWEN =3D 1; > > The symbol OSCCON itself refers to the entire register. If it were a > struct you wouldn' tbe able to say things like > > OSCCON =3D 0x1234; > > so the struct has a different name. Almost always the register name > followed by "bits". > > But once in a while there are surprises, so don't be shy about studying > the .h file. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .