View previous topic :: View next topic |
Author |
Message |
mike holeton Guest
|
Error with #byte and struct |
Posted: Wed Jun 01, 2005 10:28 pm |
|
|
The following is giving me an error on my P18F2680/4680 device. Anyone have a solution?
union {
struct {
int1 FILHIT0:1;
int1 FILHIT1:1;
int1 FILHIT2:1;
int1 FILHIT3:1;
int1 FILHIT4:1;
int1 RTRRO :1;
int1 RXM1 :1;
int1 RXFUL :1;
};
struct {
int1 TXPRI0:1;
int1 TXPRI1:1;
int1 RTREN :1;
int1 TXREQ :1;
int1 TXERR :1;
int1 TXLARB:1;
int1 TXABT :1;
int1 TXBIF :1;
};
} B1CON;
#BYTE B1CON=0xE30
Thanks
Mike |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 01, 2005 10:39 pm |
|
|
It might be helpful if you told us what compiler version you have
and what error message you're getting -- just so we're working
on the same problem. |
|
|
Ttelmah Guest
|
|
Posted: Thu Jun 02, 2005 2:56 am |
|
|
One comment. You are not assigning names to the union sub-parts. The individual structures in a union, must have names, or they can never be accessed. So:
[code]
union {
struct {
int1 FILHIT0:1;
int1 FILHIT1:1;
int1 FILHIT2:1;
int1 FILHIT3:1;
int1 FILHIT4:1;
int1 RTRRO :1;
int1 RXM1 :1;
int1 RXFUL :1;
}A;
struct {
int1 TXPRI0:1;
int1 TXPRI1:1;
int1 RTREN :1;
int1 TXREQ :1;
int1 TXERR :1;
int1 TXLARB:1;
int1 TXABT :1;
int1 TXBIF :1;
}B;
} B1CON;
Would then allow the bits to be accessed as B1CON.A.RXFUL etc.
As it stands, the union definition, contains two structure 'descriptions', but no actual structure defintions, and as such has no size.
Just about any C will complain about this.
Best Wishes |
|
|
mike holeton Guest
|
|
Posted: Thu Jun 02, 2005 10:19 am |
|
|
Thanks for the advice. I'm not so sure at the moment that names will solve all of the problem. I'm using the CCS IDE environment and version 3.225. |
|
|
Guest
|
|
Posted: Thu Jun 02, 2005 10:22 am |
|
|
Also what I'm trying to do is asign names to bits in the structs under the union for the different modes in the special registers. It makes it easier to write and keep track of the modes and bits. |
|
|
|