hi there, i have struct with the problem.I'm writing a code for DS12887,And typedef two structures in the header file.It is normal before writing a function. But now the error C141. I am more confused. Ask for The help Header file:
#include <stdio.h> #include <absacc.h> typedef struct { ...... }stTimeStr; typedef struct { ...... }stDsStatus; void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime); void SetClkTime(stTimeStr* stClkTime); void SetAlmTime(stTimeStr* stAlmTime); void GetDSStatus(stDsStatus* stStat);
C Source file:
#include <stdio.h> #include <absacc.h> #include "DS12887.h" void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime) { ...... } void SetClkTime(stTimeStr* stClkTime) { ...... } void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime) { ...... } void GetDSStatus(stDsStatus* stStat) { ...... } void GetDSStatus(stDsStatus* stStat) { ...... }
Good morning....thanks for your help....... I'm try change code as this tip....chang "byte_1" to "unsigned char".Like this:
typedef struct { unsigned char ucSECS; unsigned char ucMINS; unsigned char ucHRS; unsigned char ucWEEK; unsigned char ucDAY; unsigned char ucMON; unsigned char ucYR; unsigned char ucCENT; }stClockTime; typedef struct { unsigned char ucSECS; unsigned char ucMINS; unsigned char ucHRS; }stAlarmTime; typedef struct { unsigned char ucStatsBit; unsigned char ucSeletWord; }stDsStatus;
But......But did not work...... It's so strange ........
Does C51 insist on having a tag for the struct declaration ... ?
so,i feel very strange, If i chang code like this,then no error:
#include <stdio.h> #include <absacc.h> #include "../ComUnit/ComUnit.h" #define RDADDR XBYTE[0xfb04] #define WR1ADDR XBYTE[0xfb01] #define WR0ADDR XBYTE[0xfb00] /************** definitions unique to high-speed micros **************/ //sfr CKCON = 0x8e; /***************************** Defines ********************************/ #define CLK_SECS XBYTE[0xfb00] /* time, date & alarm regs */ #define CLK_SECS_ALM XBYTE[0xfb01] #define CLK_MINS XBYTE[0xfb02] #define CLK_MINS_ALM XBYTE[0xfb03] #define CLK_HRS XBYTE[0xfb04] #define CLK_HRS_ALM XBYTE[0xfb05] #define CLK_DOW XBYTE[0xfb06] /*Day For Week*/ #define CLK_DOM XBYTE[0xfb07] /*Day For Mouth*/ #define CLK_MON XBYTE[0xfb08] #define CLK_YR XBYTE[0xfb09] #define REGA XBYTE[0xfb0a] #define REGB XBYTE[0xfb0b] #define REGC XBYTE[0xfb0c] #define REGD XBYTE[0xfb0d] #define CLK_CENTTURY XBYTE[0xfb32] #define RS2 0x0f #define RS4 0x0e #define RS8 0x0d #define RS16 0x0c #define RS32 0x0b #define RS64 0x0a #define RS128 0x09 #define RS256 0x08 #define RS512 0x07 #define RS1024 0x06 #define RS2048 0x05 #define RS4096 0x04 #define RS8192 0x03 #define VRT 0x80 #define E32K 0x40 #define DVX 0x01 #define C887 0x02 #define VRT_SET 0x04 #define VRT2_SET 0x08 #define VLDMDL 0x10 #define CRCSEROK 0x20 //Order Day For Week:Sun,Mon,Tue,Wed,Thu,Fri,Sat0 typedef struct { unsigned char ucSECS; unsigned char ucMINS; unsigned char ucHRS; unsigned char ucWEEK; unsigned char ucDAY; unsigned char ucMON; unsigned char ucYR; unsigned char ucCENT; }stClockTime; typedef struct { unsigned char ucSECS; unsigned char ucMINS; unsigned char ucHRS; }stAlarmTime; typedef struct { unsigned char ucStatsBit; unsigned char ucSeletWord; }stDsStatus; //Initialization DS12C887 void InitaliseDS(stTimeStr* stClkTime,stTimeStr* stAlmTime) { REGA = 0xad; REGB = 0xa6; if(stClkTime->ucSECS > 0x80) return; else SetClkTime(stClkTime); if(stAlmTime->ucSECS > 0x80) return; else SetAlmTime(stAlmTime); } //Set Clock Time void SetClkTime(stTimeStr* stClkTime) { } //Set Alarm Time void SetAlmTime(stAlarmTime* stAlmTime) { } //Get DS12C887 Status WORD & BIT/ void GetDSStatus(stDsStatus* stStat) { byte_1 uStatus = 0x00; byte_1 ucTemp = 0x00; ucTemp = REGA; ucTemp = ucTemp & 0x7f; stStat->ucSeletWord = ucTemp; ucTemp = ucTemp | ((REGB& 0x07)<<1); stStat->ucStatsBit = stStat->ucStatsBit | ucTemp; ucTemp = REGC & 0xf0; stStat->ucStatsBit = ucTemp; }
have a look at the file with byte1 defined (BTW I do NOT like your byte2=int, an int is not a byte) I will bet dollars to doughnuts there is an #if or #ifdef that disables the byte1 deinition
Sorry - what, exactly, did you change?
Sorry - what, exactly, did you change? as I suggested above byte1 to unsigned char
But (s)he said (s)he'd tried that before, and it didn't work:
13-Feb-2017 01:04 GMT: I'm try change code as this tip....chang "byte_1" to "unsigned char" ... But......But did not work.
13-Feb-2017 12:41 GMT: so,i feel very strange, If i chang code like this,then no error
So my question was what else changed to make it work?
will....OK I don't use byte2=int right now. By the way,I don't like doughnuts......If you come to China, I invite you to Anhui cuisine.......
Can you tell me your e-mail,please? i can send source code to u....
My e-mail is zhanghongkun1984@gmail.com
how would my e-mail (which I would not send you anyhow, what is wrong with communicating in the forum) help you communicate with micro (u)?
Private consultancy would be chargeable
What am I missing?
You asked what had changed. The OP offered to send you the code to look at and, presumably, determine for yourself what had changed.
Are you saying you are stating that you would pay the OP for his assistance in telling you the difference???
Will...all right.Can i upload file in this forum? I can upload the source code for download.....
All right....I thought the atmosphere like a Chinese forum...... How can upload file in this Thread?
The forum doesn't have any upload.
But how hard is it to figure out if there exists any type byte_1, and if it is conditionally disabled or not? Or if it's missing just add that as a type yourself?
You are expected to be able to take care of much more complex problems than that.