Actually - it could in fact be me who is confused. I cheerfully admit that I don't grok "C". What I was commenting on=20 was that register RA is in RAM Page 0 while TRISA is in RAM Page 1. If that's not what you are doing, then I got it wrong. dwayne At 11:02 AM 4/22/2015, Nathan House wrote: >Accidentally hit ctrl+enter, which sends the email in gmail :-/ > >Attempt #2: > >I'm a little confused by your statement. Since the structs are unioned >together, setting a bit inside either of them: > >TRISAbits.RA0 =3D 1; >TRISAbits.TRISA0 =3D 1; > >Sets the same bit in memory. > >Can you elaborate what you mean when saying "the registers are at the same >address in different RAM pages"? > >Thanks! > >Nate > >I'm a college student, take it easy on me ;-) > >Check out my small hobby electronics business! >www.foxytronics.com > >On Wed, Apr 22, 2015 at 12:59 PM, Nathan House >wrote: > > > >Note that your first example (RA & TRISA) are *not* the same > > >thing. Yes - the definitions are the same but the registers are at > > >the same address in different RAM pages. > > > > I'm a little confused by your statement. Since the structs are unioned > > together, setting a bit inside them via one of these statements: > > > > > > ---- > > > > I'm a college student, take it easy on me ;-) > > > > Check out my small hobby electronics business! > > www.foxytronics.com > > > > On Wed, Apr 22, 2015 at 11:22 AM, Dwayne Reid > > wrote: > > > >> A couple of reasons. > >> > >> 1) Microchip has changed the names of certain registers and bit names > >> over the years. > >> 2) Legacy code written before those names were changed will compile > >> cleanly and give the same results. > >> > >> I do the same thing in my code: I'll include defines for each of the > >> different names that I've used over the years but changed along the wa= y. > >> > >> Note that your first example (RA & TRISA) are *not* the same > >> thing. Yes - the definitions are the same but the registers are at > >> the same address in different RAM pages. > >> > >> That said: I use exactly those same shortcuts in my code. I simply > >> ensure that I am on the correct RAM page when doing so. > >> > >> dwayne > >> > >> > >> At 11:59 AM 4/20/2015, Nathan House wrote: > >> >Hi, > >> > > >> >The main.pre file in my MPLAB X project seems to show the definitions= for > >> >the configuration registers. One example is this: > >> > > >> >typedef union { > >> >struct { > >> >unsigned TRISA0 :1; > >> >unsigned TRISA1 :1; > >> >unsigned TRISA2 :1; > >> >unsigned TRISA3 :1; > >> >unsigned TRISA4 :1; > >> >unsigned TRISA5 :1; > >> >unsigned TRISA6 :1; > >> >unsigned TRISA7 :1; > >> >}; > >> >struct { > >> >unsigned RA0 :1; > >> >unsigned RA1 :1; > >> >unsigned RA2 :1; > >> >unsigned RA3 :1; > >> >unsigned RA4 :1; > >> >unsigned RA5 :1; > >> >unsigned RA6 :1; > >> >unsigned RA7 :1; > >> >}; > >> >} TRISAbits_t; > >> >extern volatile TRISAbits_t TRISAbits @ 0xF92; > >> > > >> >What is the point of making the same bits accessible through more tha= n > >> one > >> >name? > >> > > >> >I.e. the following lines of code are identical, correct? > >> > > >> >TRISAbits.RA0 =3D 1; > >> >TRISAbits.TRISA0 =3D 1; > >> > > >> >The LATAbits definition is even more convoluted: > >> > > >> >typedef union { > >> >struct { > >> >unsigned LATA0 :1; > >> >unsigned LATA1 :1; > >> >unsigned LATA2 :1; > >> >unsigned LATA3 :1; > >> >unsigned LATA4 :1; > >> >unsigned LATA5 :1; > >> >unsigned LATA6 :1; > >> >unsigned LATA7 :1; > >> >}; > >> >struct { > >> >unsigned LA0 :1; > >> >}; > >> >struct { > >> >unsigned :1; > >> >unsigned LA1 :1; > >> >}; > >> >struct { > >> >unsigned :2; > >> >unsigned LA2 :1; > >> >}; > >> >struct { > >> >unsigned :3; > >> >unsigned LA3 :1; > >> >}; > >> >struct { > >> >unsigned :4; > >> >unsigned LA4 :1; > >> >}; > >> >struct { > >> >unsigned :5; > >> >unsigned LA5 :1; > >> >}; > >> >struct { > >> >unsigned :6; > >> >unsigned LA6 :1; > >> >}; > >> >struct { > >> >unsigned :7; > >> >unsigned LA7 :1; > >> >}; > >> >} LATAbits_t; > >> >extern volatile LATAbits_t LATAbits @ 0xF89; > >> > > >> >I don't know why they union'd a separate struct for each of the bits > >> >instead of putting them all in one struct like with TRISAbits, but th= e > >> same > >> >question applies to this as well. > >> > > >> >What's the point of all that redundancy? > >> > > >> >Thanks, > >> > > >> >Nate > >> > > >> >----- > >> > > >> >I'm a college student, take it easy on me ;-) --=20 Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax www.trinity-electronics.com Custom Electronics Design and Manufacturing --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .