| ??? 10/08/06 09:57 Modified: 10/08/06 10:01 Read: times |
#126003 - shift register in C |
I wanted an 8 bit long shift register in C so I did a typedef to define a bit field like so
typedef struct shift{ unsigned char pb0:1; unsigned char pb1:1; unsigned char pb2:1; unsigned char pb3:1; unsigned char pb4:1; unsigned char pb5:1; unsigned char pb6:1; unsigned char pb7:1; }shift; static shift db; and then because you cannot do a shift on a bit field I do something like db.pb7=db.pb6; bd.pb6=db.pb5; ..... and so on but there must be an easier way of doing this. anyone got any clues? oh I didnt use a simple shift=shift<<1 because i wanted to do strange stuff with the individual bits and using bit masks isnt very suitable. |
| Topic | Author | Date |
| shift register in C | 01/01/70 00:00 | |
| bdata? | 01/01/70 00:00 | |
| I'm not sure | 01/01/70 00:00 | |
| ah well,all sorted now | 01/01/70 00:00 | |
Try this | 01/01/70 00:00 |



