Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. easyts

    Extern union

    Oh! Thanks! You're right! I propose another shorter solution: In 'global.h': extern __saddr union bts { unsigned char byte; struct { unsigned char b0:1; unsigned char b1:1; unsigned char b2:1; unsigned char b3:1; unsigned char b4:1; unsigned char b5:1; unsigned...
  2. easyts

    Extern union

    I forgot to say that if I declare the union as follow in "global.h" (without extern): __saddr union bts { unsigned char byte; struct { unsigned char b0:1; unsigned char b1:1; unsigned char b2:1; unsigned char b3:1; unsigned char b4:1; unsigned char b5:1; unsigned...
  3. easyts

    Extern union

    Hi everyone, I'm finishing a code for a NEC uProcessor and I'm having problems with unions. At the beginning of writing this code I wrote everything in 1 file, but after I decided to divide this code in various modules. I have some unions that are used in different modules, so I have to...
  4. easyts

    Complicated struct/union

    Hi, I finally could solve the problem... This is the code I use. __saddr union mess0x100 { struct { unsigned short rpm:16; unsigned short res3:16; union speed_sensor1 { unsigned short speed:12; struct { unsigned char dummy; unsigned char dummy2:4...
  5. easyts

    Complicated struct/union

    Well, I'm using a NEC uP of 8 bits, and the compiler is the IAR Embedded Workbench. Salem, you're right. I'm having problems because of the compiler is allocating bits from LSB to MSB when I need MSB to LSB. xwb, I'll be aware of the 'packed' option. Thanks, I'll let you know how it ends...
  6. easyts

    Complicated struct/union

    Well, I've tried to solve it and it almost works correctly, but not all. ********************************* __saddr union mess0x100 { struct {unsigned char sensor:4; unsigned short speed:12; unsigned char res0:8; unsigned short rpm:16; unsigned char res1:1; unsigned char...
  7. easyts

    Complicated struct/union

    Thanks for your reply. What you've done it's not exactly what I want .This code works correctly but is not useful because I receive 4 kinds of messages, and each of them have 8 bytes, where the variables can be 1 byte or only some bits (as the 'seed' variable I showe you before). So if I have...
  8. easyts

    Complicated struct/union

    Hi, I'm writing a code and I have a problem with structs and unions. I read 8 bytes (RXBnD[8]) from an external system, and each of these 8 bytes are structured in 8 bits: ******************************** __saddr union aux_bits2 { struct {unsigned char b0:1; unsigned char b1:1...

Part and Inventory Search

Back
Top