On Wed, Mar 18, 2015 at 9:01 PM, Bob Ammerman wrote= : > You are using 'anonymous' structs/unions. I always found this potentially > problematical, so I never use it. If you do your definition like this: > >> typedef union { >> struct >> { >> unsigned ENC1UP :1; >> unsigned ENC1DN :1; >> unsigned ENC2UP :1; >> unsigned ENC2DN :1; >> unsigned ENC3UP :1; >> unsigned ENC3DN :1; >> unsigned ENC4UP :1; >> unsigned ENC4DN :1; >> } bits; >> struct >> { >> unsigned all :8; >> } all; >> } T; > > Then you can say: > > T t; > t.bits.ENC3DN =3D 1; > t.all.all =3D 0; Hm...interesting. It took me about 45 minutes to get this working, mainly because the compiler suddenly decided to not like how I was declaring the variable, even though I hadn't touched that part of the code, and it was working last night. Awesome. I'm sure I did something, but who knows what. So yes, now it appears that this is working. I will have to do some simulation to make sure it's writing to the bits correctly, but at least it compiles now. To the 8/16bit point that a few people have raised. Is it that by declaring as "unsigned XXX :1;" I'm declaring XXX to be a single bit out of and unsigned int which is 16 bits? I just want to make sure I understand. I thought that by declaring only 8 bits the compiler would make it an 8 bit variable. But then, I've been used to assembly for so long that I keep forgetting things aren't automatically 8 bits. Thanks! Josh --=20 A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. -Douglas Adams --=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 .