This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiling Error C:141 near 'void'

Compiling Error C:141 syntax error near 'void'

Please help me to compile this file. Need to create a Hex code of it finally. Also it seems a bigger fie and cannot be compiled with free versin ??? help me converting to hex code

/* Automated tap n flush system code- */
#include <regx51.h>
#define MAXLINE 250
/* ----------------------- led on/off -------------------------------- */
#define l1_on P3_0 = 0
#define l1_off P3_0 = 1
#define l2_on P1_1 = 0
#define l2_off P1_1 = 1
#define IR_on P3_1 = 0; P3_2 = 0
#define IR_off P3_1 = 1; P3_2 = 1
/*-------------------- solenoid on/off ------------------------------*/
#define solenoid_on P3_0 = 0
#define solenoid_off P3_0 = 1
/*------------------- assign pins to switches -----------------------*/
#define sw1 |P1_7
#define sw2 |P1_6
#define sw3 |P1_5
#define sw4 |P1_4
#define sw5 |P1_3
#define sw6 |P1_2
#define sw7 |P3_4
#define sw8 |P3_5
#define sensor |P3_3
/*------------------- global status variables -----------------------*/
volatile char sensor_delay = 0; /* sensor detect hysterisis delay */
volatile char solenoid_delay = 0; /* solenoid start delay */
volatile char solenoid_duration = 0; /* solenoid duration */
volatile char start_mode = 0; /* '0' means solenoid starts after sensor gaining detection, '1' means after sensor losing detection */
volatile char stop_mode= 0; /* '0' means solenoid duration counts from its start, '1' means counts after sensor losing detection */
/* ------------------- delay options in seconds ---------------------- */
volatile char sensor_delay_s[] = {1,3,5,7}; /* sensor detect hysterisis delay */
volatile char solenoid_delay_s[] = {1,2,3,5}; /* solenoid start delay */
volatile char solenoid_duration_s[] = {1,5,8,10}; /* solenoid duration
----------------- 'x'seconds delay function ----------------------- */
void delay_s(char x)
{ char y; /* temporary variable */

TR0 = 1; /* start the timer */ while(x) /* loops for 'x' seconds */ {y = 0x64; /* loops 100 times */ while(y) /* loops for approx 'x/100' secs */ {if(TF0) /* check timer overflow */ {y--; TF0 = 0; /* reset overflow flag */ } x--; /* reduce number of seconds to go */ } TR0 = 0;TL0 = 0;TH0 = 0;TF0 = 0; /* stop & reset the timer */ }
/*---------------- 'x/10'seconds delay function --------------------- */
void delay_ss(char x)
{ char y; // temporary variable TR0 = 1; // start the timer while(x) // loops for 'x/10' seconds { y = 0x0A; // loops 10 times while(y) /* loops for approx 'x/100' secs */ { if(TF0) /* check timer overflow */ { y--; TF0 = 0; /* reset overflow flag */ } } x--; /* reduce number of seconds to go */ } TR0 = 0;TL0 = 0;TH0 = 0;TF0 = 0; /* stop & reset the timer */
} /*------------------- sensor detect function ------------------------ */
void check_sensor_detect()
{ char x,y; /* temporary variables */ TMOD = T1_M1; /* set timer mode */ TL1 = 256-12; /* set timer frequency to 76.8kHz making IR led frequency as 38.4kHz at 50% duty cycle */ TR1 = 1; /* start the timer */

x = sensor_delay_s[sensor_delay]; y = 0; while(x+1) /* loops till 'x+1' consecutive detects */ { if(TF1) /* check timer overflow */ { TR1 = 0; /* stop the timer */ TF1 = 0; /* reset overflow flag */ TL1 = 256-12; /* reset timer frequency */ if(y<60) /* run IR led at 38kHz in bursts of 30 cycles once every second */ { TR1 = 1; /* start timer */

if(P3_1) { IR_on; } else { IR_off; } if(y==40) /* check sensor at end of 20 cycles */ { if(P3_3) { l2_on; x--; } else { l2_off; x = sensor_delay_s[sensor_delay]; } } y++; } else { y = 0; if (x == sensor_delay_s[sensor_delay]) {l2_on; delay_ss(1); l2_off; } delay_s(1); TR1=1; } } } TR1 = 0; /* stop the timer */ l2_off; x=3; while(x) /* blinking of led 3 times to denote sensor detect */ { l2_on; delay_ss(1); l2_off; delay_ss(1); x--; }
} /* ------------------- sensor release function ------------------------ */
void check_sensor_release()
{ char x,y; /* temporary variables */ TMOD = T1_M1; /* set timer mode */ TL1 = 256-12; /* set timer frequency to 76.8kHz making IR led frequency as 38.4kHz at 50% duty cycle */ TR1 = 1; /* start the timer */ x = sensor_delay_s[sensor_delay]; y = 0;

while(x+1) /* loops till 'x+1' consecutive detects */ { if(TF1) /* check timer overflow */ { TR1 = 0; /* stop the timer */ TF1 = 0; /* reset overflow flag */ TL1 = 256-12; /* reset timer frequency */

if(y<60) { TR1 = 1; /* start timer */ if(P3_1) { IR_on; } else { IR_off; } if(y==40) { if(sensor) { l2_off; x--; } else { l2_on; x = sensor_delay_s[sensor_delay]; } }

y++; } else { y = 0; if (x == sensor_delay_s[sensor_delay]) {l2_off; delay_ss(1); l2_on; } delay_s(1); TR1=1; } } } TR1 = 0; /* stop the timer */ l2_off;

x=3; while(x) /* blinking of led 3 times to denote sensor release */ { l2_on; delay_ss(1); l2_off; delay_ss(1); x--; }
} /* ---------------------- main function ------------------------------ */
void main (void)
{ char x=4; /* temporary variable */ P1 = 0xFF; /* set all pins of port 1 */ P3 = 0xFF; /* set all pins of port 3 */ delay_s(2); } while(x) /* startup blinking of led x times */ { l2_on; delay_ss(1); l2_off; delay_ss(1); x--; } while(1) /* infinite loop */ { /* setting configuration from switch positions */ if(sw1) sensor_delay = 1; if(sw2) sensor_delay = 1<<1;

if(sw3) solenoid_delay = 1; if(sw4) solenoid_delay = 1<<1;

if(sw5) solenoid_duration = 1; if(sw6) solenoid_duration = 1<<1;

if(sw7) start_mode = 1; else start_mode = 0;

if(sw8) stop_mode = 1; else stop_mode = 0;

delay_s(2); x = 5; } while(x) /* blinking of led 5 times to denote configuration complete */ { l2_on; delay_ss(1); l2_off; delay_ss(1); x--; } delay_s(1); check_sensor_detect(); if(start_mode) check_sensor_release(); delay_s(solenoid_delay_s[solenoid_delay]); solenoid_on; if(stop_mode) check_sensor_release(); delay_s(solenoid_duration_s[solenoid_duration]); solenoid_off; x = 20; sensor_delay = 0; solenoid_delay = 0; solenoid_duration = 0; start_mode = 0; stop_mode = 0; }
}

0