Struct C:访问成员数为奇数的结构时出现地址陷阱错误
我正在使用MPLABX和编译器xc16 gcc为16位dsPIC33CH128MP508微控制器开发。我正在制作代码,以便通过I2C从RTC读取。 我已经定义了以下结构:Struct C:访问成员数为奇数的结构时出现地址陷阱错误,struct,pad,packed,xc16,Struct,Pad,Packed,Xc16,我正在使用MPLABX和编译器xc16 gcc为16位dsPIC33CH128MP508微控制器开发。我正在制作代码,以便通过I2C从RTC读取。 我已经定义了以下结构: typedef struct tagRTC_VL_SECONDSBITS{ uint8_t SECONDS: 7 ; uint8_t VL:1 ; /* 0: clock integrity is guarantee */ }sRTC_VL_SECONDSBITS_t; typedef struc
typedef struct tagRTC_VL_SECONDSBITS{
uint8_t SECONDS: 7 ;
uint8_t VL:1 ; /* 0: clock integrity is guarantee */
}sRTC_VL_SECONDSBITS_t;
typedef struct tagRTC_MINUTESBITS{
uint8_t MINUTES: 7 ;
uint8_t :1 ;
}sRTC_MINUTESBITS_t;
typedef struct tagRTC_HOURSBITS{
uint8_t HOURS: 6 ;
uint8_t :2 ;
}sRTC_HOURSBITS_t;
typedef struct tagRTC_DAYSBITS{
uint8_t DAYS: 6 ;
uint8_t :2 ;
}sRTC_DAYSBITS_t;
typedef struct tagRTC_WEEKDAYSBITS{
uint8_t WEEKDAYS: 3 ;
uint8_t :5 ;
}sRTC_WEEKDAYSBITS_t;
typedef struct tagRTC_CENTURY_MONTHSBITS{
uint8_t MONTHS: 5 ;
uint8_t :2 ;
uint8_t C:1 ;
}sRTC_CENTURY_MONTHSBITS_t;
typedef struct tagRTC_YEARSBITS{
uint8_t YEARS ;
}sRTC_YEARSBITS_t;
typedef struct tagRTC_TIME{
sRTC_VL_SECONDSBITS_t sec;
sRTC_MINUTESBITS_t min ;
sRTC_HOURSBITS_t hr ;
sRTC_DAYSBITS_t day ;
sRTC_WEEKDAYSBITS_t wDay ;
sRTC_CENTURY_MONTHSBITS_t month ;
sRTC_YEARSBITS_t year ;
}sRTC_TIME_t ;
structsRTC\u TIME\t
的问题有奇数个成员,内存对齐由编译器自动打包。从RTC读取还需要打包结构
当尝试读取第一个成员sec
时,使用TRAPS\u ADDRESS\u ERR=2、/**ADDRESS error trap vector*/
读取代码陷阱
sRTC\u TIME\t TIME代码>
second_reading=time.sec.SECONDS代码>
当我们在structsRTC\u TIME\t
中添加第八个虚拟成员时,没有错误
这个问题的根源可能是什么