本帖最后由 songtao0728 于 2015-1-20 14:45 编辑
代码如下
typedef union{
unsigned long State;
struct {
unsigned long Bit0:1; //-> Hour high bit
unsigned long Bit1:1; //-> Voltage radix point sybmol
unsigned long Bit2:1; //-> Battery left 2
unsigned long Bit3:1; //-> Battery left 1
unsigned long Bit4:1; //-> Second
unsigned long Bit5:1; //-> ODO
unsigned long Bit6:1; //-> REMN
unsigned long Bit7:1; //-> People and Bike **
unsigned long Bit8:1; //-> Battery left 3
unsigned long Bit9:1; //-> Temperature Symbol
unsigned long Bit10:1; //-> left
unsigned long Bit11:1; //-> Battery left 5
unsigned long Bit12:1; //-> Temperature "A"
unsigned long Bit13:1; //-> Temperature unit
unsigned long Bit14:1; //-> M Light
unsigned long Bit15:1; //-> Battery **
unsigned long Bit16:1; //-> Mileage radix point
unsigned long Bit17:1; //-> Voltage Unit
unsigned long Bit18:1; //-> Speed/Kilometer chinese unit
unsigned long Bit19:1; //-> Speed/Mileage unit
unsigned long Bit20:1; //-> Battery left 4
unsigned long Bit21:1; //-> Door
unsigned long Bit22:1; //-> Motor
unsigned long Bit23:1; //-> ECU
unsigned long Bit24:1; //-> EPS
unsigned long Bit25:1; //-> Right
unsigned long Bit26:1; //-> 3
unsigned long Bit27:1; //-> 2
unsigned long Bit28:1; //-> 1
unsigned long Bit29:1; //-> Low Battery **
unsigned long Bit30:1; //-> Reserved
unsigned long Bit31:1; //-> Reserved
}Sub;
} LCD_TypeDef;
我在main.c中定义一个这个类型的变量
volatile LCD_TypeDef Flags;
然后在主程序中对位进行操作,测试发现
Flags.Sub.Bit0 = 1;
~~
Flags.Sub.Bit23 = 0;
0~23赋值都没有问题,24~31就会编译不能通过
Flags.Sub.Bit24 = 0;
~~
Flags.Sub.Bit31 = 1;
提示:#error castm8 C:\DOCUME~1\LUCIEN~1\LOCALS~1\Temp\s798.cx2:2862 value too large,哪位朋友遇到过这样的问题?希望赐教.
|