![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
jacqueskleynhans
Joined: 10 Apr 2008 Posts: 109 Location: Cape Town, South Africa
|
100 Errors need 1 solution |
Posted: Sun Aug 24, 2008 7:36 am |
|
|
Hi after running my calibration routine for my accelerometer i get 100 errors
Errors are constant clearly I'm doing something wrong
Quote: | *** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 3(1,2): Expecting a declaration
*** Error 48 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(11,15): Expecting a (
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(13,14): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(14,15): Expecting a declaration
*** Error 28 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(20,21): Expecting an identifier
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(27,28): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(29,30): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(30,31): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(31,34): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(34,35): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(35,36): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(36,37): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(37,38): Expecting a declaration
*** Error 48 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(38,43): Expecting a (
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(44,45): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(45,46): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(46,47): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 23(47,48): Expecting a declaration
*** Error 48 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(11,15): Expecting a (
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(13,14): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(14,15): Expecting a declaration
*** Error 28 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(20,21): Expecting an identifier
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(27,28): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(29,30): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(30,31): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(31,34): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(34,35): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(35,36): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(36,37): Expecting a declaration
*** Error 43 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(37,38): Expecting a declaration
*** Error 48 "C:\Users\BETTIE\Documents\Work\Adc_Cal_Data.c" Line 24(38,43): Expecting a (
|
And the code for this mess is
Code: | void Calibrated_output(void);
{
//From ADC GET DATA
//X1 = Y1 = Z1 = +G values
//X2 = Y2 = Z2 = 0G values
//X3 = Y3 = Z3 = -G values
//From CAL CONSTANT
//MA_X = X1 / X2 ;
//MB_X = X2 / X3 ;
//MA_Y = Y1 / Y2 ;
//MB_Y = Y2 / Y3 ;
//MA_Z = Z1 / Z2 ;
//MB_Z = Z2 / Z3 ;
Measure_Xout(); // Get converted reading from adc
Measure_Yout(); // Get converted reading from adc
Measure_Zout(); // Get converted reading from adc
VinX = ((float)Xaxis * ((3.3/(2*X2raw)))); //Adc values get multiplies by scaling factor"(3.3v/2*X2raw))
VinY = ((float)Yaxis * ((3.3/(2*Y2raw)))); //Adc values get multiplies by scaling factor"(3.3v/2*Y2raw))
VinZ = ((float)Zaxis * ((3.3/(2*Z2raw)))); //Adc values get multiplies by scaling factor"(3.3v/2*Z2raw))
if(VinX > X2)
{
Calibrate_Output = ((VinX - X2 ) * MA_X ) + 1.65;
}else if( VinX == X2 )
{
Calibrate_Output = 0.0; //X2 which equates to 0g's ;
}else if( VinX < X2 )
{
Calibrate_Output = X2 - ((VinX - X2 ) * MB_X );
}
printf("Xcal %3.2f\n\r" ,Calibrate_Output);
Calibrate_Output = 0;
//For the case of Y
If( VinY > Y2 )
{
Calibrate_Output = (( VinY - Y2 ) * MA_Y ) + 1.65;
}else if( VinY == Y2)
{
Calibrate_Output = 0.0; //Y2 which equates to 0g's
}else if( VinY < Y2 )
{
Calibrate_Output = 1.64 - ((VinY - 1.64 ) * MB_Y );
}
printf("Ycal %3.2f\n\r" ,Calibrate_Output);
........
..
.
.
|
The difficult part for me is I'm not in the software or programming side of engineering. I'm a instrumentation student at varsity but I like to try and program but don't get much time though. I'm hope the problem above is not too big.
Kind Regards.
Jacques Kleynhans _________________ "THE ONLY EASY DAY WAS YESTERDAY" |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Aug 24, 2008 8:15 am |
|
|
Your first declaration, is terminated with a semicolon. This 'ends' the declaration. You then have a large block of code, with no name, which is not part of the declaration...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Aug 24, 2008 8:26 am |
|
|
As extra info to Ttelmah's answer:
Code: | void Calibrated_output(void);
| This line is seen by the compiler as a 'function declaration', the definition of a function name. You meant a 'function implementation', the actual function code. The difference between the two is the ';' at the end of the line... |
|
![](templates/subSilver/images/spacer.gif) |
atai21
Joined: 30 Dec 2010 Posts: 31
|
|
Posted: Wed Jan 19, 2011 2:31 am |
|
|
Quote: |
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Users\Lenovo\Desktop\temp\try\try\main.ESYM".
Clean Warning: File "C:\Users\Lenovo\Desktop\temp\try\try\main.o" doesn't exist.
Clean: Deleted file "C:\Users\Lenovo\Desktop\temp\try\try\main.ERR".
Clean: Done.
Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" +FH "C:\Users\Lenovo\Desktop\temp\try\try\main.c" +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 76 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 55(17,18): Expect ;
*** Error 51 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 56(4,8): A numeric expression must appear here
*** Error 28 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 64(24,25): Expecting an identifier comwrite
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 64(26,27): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 64(27,28): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 64(28,29): Expecting a declaration
*** Error 28 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 65(11,12): Expecting an identifier
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 65(13,14): Expecting a declaration
*** Error 48 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 66(6,9): Expecting a (
*** Error 28 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 66(26,27): Expecting an identifier
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 66(27,28): Expecting a declaration
*** Error 28 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 67(24,25): Expecting an identifier
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 67(26,27): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 67(27,28): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 67(28,29): Expecting a declaration
*** Error 28 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 68(11,12): Expecting an identifier
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 68(13,14): Expecting a declaration
*** Error 28 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 69(24,25): Expecting an identifier
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 69(26,27): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 69(27,28): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 69(28,29): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 70(2,8): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 70(8,9): Expecting a declaration
*** Error 48 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 70(9,12): Expecting a (
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 70(13,14): Expecting a declaration
*** Error 43 "C:\Users\Lenovo\Desktop\temp\try\try\sht75.c" Line 71(1,2): Expecting a declaration
26 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Wed Jan 19 16:25:44 2011
|
Code: |
///////////////////////////////////////////////////////////////////////////////
// //
// Driver file for SHT75 Temperature & Humidity Sensor //
// //
// ***** To initialise SHT75 sensor upon power up ***** //
// //
// Function : sht_init() //
// Return : none //
// //
// //
// ***** To measure and caluculate SHT75 temp & real RH ***** //
// //
// Function : sht_rd (temp, truehumid) //
// Return : temperature & true humidity in float values //
// //
///////////////////////////////////////////////////////////////////////////////
#define sht_data_pin PIN_B0
#define sht_clk_pin PIN_B1
//***** Function to alert SHT75 *****
void comstart (void)
{
output_float(sht_data_pin); //data high
output_bit(sht_clk_pin, 0); //clk low
delay_us(1);
output_bit(sht_clk_pin, 1); //clk high
delay_us(1);
output_bit(sht_data_pin, 0); //data low
delay_us(1);
output_bit(sht_clk_pin, 0); //clk low
delay_us(2);
output_bit(sht_clk_pin, 1); //clk high
delay_us(1);
output_float(sht_data_pin); //data high
delay_us(1);
output_bit(sht_clk_pin, 0); //clk low
}
//***** Function to write data to SHT75 *****
int1 comwrite (int8 iobyte)
{
int8 i, mask = 0x80;
int1 ack;
//Shift out command
delay_us(4);
for(i=0; i<8> 0) output_float(sht_data_pin); //data high if MSB high
else output_bit(sht_data_pin, 0); //data low if MSB low
delay_us(1);
output_bit(sht_clk_pin, 1); //clk high
delay_us(1);
mask = mask >> 1; //shift to next bit
}
//Shift in ack
output_bit(sht_clk_pin, 0); //clk low
delay_us(1);
ack = input(sht_data_pin); //get ack bit
output_bit(sht_clk_pin, 1); //clk high
delay_us(1);
output_bit(sht_clk_pin, 0); //clk low
return(ack);
}
//***** Function to read data from SHT75 *****
int16 comread (void)
{
int8 i;
int16 iobyte = 0;
const int16 mask0 = 0x0000;
const int16 mask1 = 0x0001;
//shift in MSB data
for(i=0; i<8; i++)
{
iobyte = iobyte << 1;
output_bit(sht_clk_pin, 1); //clk high
delay_us(1);
if (input(sht_data_pin)) iobyte |= mask1; //shift in data bit
else iobyte |= mask0;
output_bit(sht_clk_pin, 0); //clk low
delay_us(1);
}
//send ack 0 bit
output_bit(sht_data_pin, 0); //data low
delay_us(1);
output_bit(sht_clk_pin, 1); //clk high
delay_us(2);
output_bit(sht_clk_pin, 0); //clk low
delay_us(1);
output_float(sht_data_pin); //data high
//shift in LSB data
for(i=0; i<8; i++)
{
iobyte = iobyte << 1;
output_bit(sht_clk_pin, 1); //clk high
delay_us(1);
if (input(sht_data_pin)) iobyte |= mask1; //shift in data bit
else iobyte |= mask0;
output_bit(sht_clk_pin, 0); //clk low
delay_us(1);
}
//send ack 1 bit
output_float(sht_data_pin); //data high
delay_us(1);
output_bit(sht_clk_pin, 1); //clk high
delay_us(2);
output_bit(sht_clk_pin, 0); //clk low
return(iobyte);
}
//***** Function to wait for SHT75 reading *****
void comwait (void)
{
int16 sht_delay;
output_float(sht_data_pin); //data high
output_bit(sht_clk_pin, 0); //clk low
delay_us(1);
for(sht_delay=0; sht_delay<30000; sht_delay++) // wait for max 300ms
{
if (!input(sht_data_pin)) break; //if sht_data_pin low, SHT75 ready
delay_us(10);
}
}
//***** Function to reset SHT75 communication *****
void comreset (void)
{
int8 i;
output_float(sht_data_pin); //data high
output_bit(sht_clk_pin, 0); //clk low
delay_us(2);
for(i=0; i<9; i++)
{
output_bit(sht_clk_pin, 1); //toggle clk 9 times
delay_us(2);
output_bit(sht_clk_pin, 0);
delay_us(2);
}
comstart();
}
//***** Function to soft reset SHT75 *****
void sht_soft_reset (void)
{
comreset(); //SHT75 communication reset
comwrite(0x1e); //send SHT75 reset command
delay_ms(15); //pause 15 ms
}
//***** Function to measure SHT75 temperature *****
int16 measuretemp (void)
{
int1 ack;
int16 iobyte;
comstart(); //alert SHT75
ack = comwrite(0x03); //send measure temp command and read ack status
if(ack == 1) return;
comwait(); //wait for SHT75 measurement to complete
iobyte = comread(); //read SHT75 temp data
return(iobyte);
}
//***** Function to measure SHT75 RH *****
int16 measurehumid (void)
{
int1 ack;
int16 iobyte;
comstart(); //alert SHT75
ack = comwrite(0x05); //send measure RH command and read ack status
if(ack == 1) return;
comwait(); //wait for SHT75 measurement to complete
iobyte = comread(); //read SHT75 temp data
return(iobyte);
}
//***** Function to calculate SHT75 temp & RH *****
void calculate_data (int16 temp, int16 humid, float & tc, float & rhlin, float & rhtrue)
{
float truehumid1, rh;
//calculate temperature reading
tc = ((float) temp * 0.01) - 40.0;
//calculate Real RH reading
rh = (float) humid;
rhlin = (rh * 0.0405) - (rh * rh * 0.0000028) - 4.0;
//calculate True RH reading
rhtrue = ((tc - 25.0) * (0.01 + (0.00008 * rh))) + rhlin;
}
//***** Function to measure & calculate SHT75 temp & RH *****
void sht_rd (float & temp, float & truehumid)
{
int16 restemp, reshumid;
float realhumid;
restemp = 0; truehumid = 0;
restemp = measuretemp(); //measure temp
reshumid = measurehumid(); //measure RH
calculate_data (restemp, reshumid, temp, realhumid, truehumid); //calculate temp & RH
}
//***** Function to initialise SHT75 on power-up *****
void sht_init (void)
{
comreset(); //reset SHT75
delay_ms(20); //delay for power-up
}
|
Good day all,
Can someone help me on those error. Me too are like jacqueskleynhans, who are right now trying to learn c programming. Really hope someone can help me. |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jan 19, 2011 3:01 am |
|
|
Code: |
for(i=0; i<8> 0) output_float(sht_data_pin); //data high if MSB high
else output_bit(sht_data_pin, 0); //data low if MSB low
|
Makes no sense. else is part of an if statement NOT a for. You also end the for with } but do not have the corrosponding openeing { after the for.
Your for statement is wrong as well! |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Jan 19, 2011 3:04 am |
|
|
Simply start with the first error message and check the syntax, apparently something is wrong here:
You also have non-matching parantheses and similar basic issues. |
|
![](templates/subSilver/images/spacer.gif) |
atai21
Joined: 30 Dec 2010 Posts: 31
|
|
Posted: Wed Jan 19, 2011 3:11 am |
|
|
i'm sorry but i get this code from one of the thread "sht75 driver"..i will try working on it.tqvm for your fast response |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Wed Jan 19, 2011 4:57 am |
|
|
Start with the sht75 driver. Note that _with it_, there is a 'main'. You need to have the driver in an include file (sht75.c), and the main (perhaps main.c), and then compile the latter. This then loads the driver.
The posted code compiles _without error_.
The line in the original code, bears little resemblance to the line in the code you have posted:
Yours:
Code: |
for(i=0; i<8> 0) output_float(sht_data_pin); //data high if MSB high
else output_bit(sht_data_pin, 0); //data low if MSB low
|
Original:
Code: |
for(i=0; i<8; i++)
{
output_bit(sht_clk_pin, 0); //clk low
if((iobyte & mask) > 0) output_float(sht_data_pin); //data high if MSB high
else output_bit(sht_data_pin, 0); //data low if MSB low
|
Use 'cut and paste', rather than retyping. If retyping, _read_ and try to understand what you are typing.....
The errors are in your typing....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|