hi there, i have struct with the problem.in the multiplexing of the 7-segment display. as i complited the 7-segment display multiplexing. prog.is working properly. but when i moved to the next some advance step it give's the above msg. i think the problem is in the variable passing between function. because as i try to pass the local data to globle side
can any one explain me the passing the value's between two function. the function returning the value is in the main function and the function which recive's the value is out of the main function the function which recive's the value is out of the main function is the part of the interrupt routine the function which sending or returning the value is the part of main function
"i think the problem is in the variable passing between function."
Why do you think that?
The message is a syntax error; ie, what you have written is not valid C51 syntax.
dictionary.cambridge.org/define.asp
http://www.keil.com/support/man/docs/c51/c51_c141.htm
This could be a simple typo - eg, missing semicolon or spelling mistake.
Note that it says "near" - this probably means that the error is somewhere before the word "unsigned"
i checked all the thing's and only after that posted the msg. This could be a simple typo - eg, missing semicolon or spelling mistake. there is no such type of mistake
"can any one explain me the passing the values between two function"
This is standard 'C' - nothing specifically to do with Keil at all. Therefore, any 'C' textbook should be able to help you.
See: c-faq.com/.../srcfiles.html and the associated links
"there is no such type of mistake"
Well, clearly there is - or you wouldn't get the error!
The error relates specifically tou your source text - so, if you want help with it, you are going to have to post that source!
Please be sure to read the instructions for posting code: http://www.keil.com/forum/tips.asp
Use spaces to lay-out your code - not TABs (the interpretation of TABs is unpredictable).
Use copy-and-paste - do not manually re-type the code into your post!
thank's andy but when i face the problem i done the each and every thing for which i capable but i can not get the way to of it. here i providing the sample or small model fo the problematic code hope u will help me
unsigned int i,j,k,l,a; unsigned int sft = 1; void disp(unsigned int a); unsigned int go (void); /*interrupt setting (routine)***/ void TMR_0(void) interrupt 1 { TF0 = 0; TR0 = 0; TH0 = 0xAA; disp(unsigned int); TL0 = 0x00; TR0 = 1; } void disp(unsigned int a) { sft = a; DECOD1 = 0; /* 7-segment 1st display */ DECOD2 = 0; DECOD3 = 0; P0 = number_code[i]; if(sft != 1) {disp_wait();} blink(); } /**** main prog******/ void main() { P0 = 0x3f; /* initial port setting */ P1 = 0xff; P2 = 0xf8; P3 = 0xff; IE = 0x82;/*timer and interrept setting*/ TMOD = 0x01; TH0 = 0xAA; TL0 = 0x00; TR0 = 1; while(1) { unsigned int go(); } } unsigned int go() { /***shift key press identification *********/ if(KEY2_SFT == 0) { sft++; sft_wait(); KEY2_SFT = 1; if(sft > 4) {sft = 1;} a = sft; return(a); }
unnessary code is omited can any one suggest the nessary change in this code.
Where, precisely, does error C141: syntax error near 'unsigned' occur in this code?
/*interrupt setting (routine)***/
void TMR_0(void) interrupt 1 { TF0 = 0; TR0 = 0; TH0 = 0xAA; disp(unsigned int); at this point TL0 = 0x00; TR0 = 1; } </prr>
Well, the error should be obvious!
But we've all been at that point of staring at a piece of code for so long that we can no longer see the wood for the trees!
So, back to basics: how do you call a function in 'C'? How do you supply parameters when you call a fucntion in 'C' - what should go within the parentheses...?
What is the value or variable that you actually want to pass to the display() function at this point...?
unsigned int go() { /***shift key press identification *********/ if(KEY2_SFT == 0) { sft++; sft_wait(); KEY2_SFT = 1; if(sft > 4) {sft = 1;} a = sft; i want to pass this value return(a); }
/*********************************************/
disp(unsigned int); at this point
OK, let's take this one step at a time.
How do you pass a parameter to a function when you call it?
Insert an appropriate call to my_function in the code below, passing fred as its parameter:
void my_function( unsigned int x ); // function prototype void main( void ) { unsigned int fred; // Insert a call here }
void disp(unsigned int a); //it going to used in the interrupt unsigned int go (void); //going to used in main function void main() { P0 = 0x3f; /* initial port setting */ P1 = 0xff; P2 = 0xf8; P3 = 0xff; IE = 0x82;/*timer and interrept setting*/ TMOD = 0x01; TH0 = 0xAA; TL0 = 0x00; TR0 = 1; while(1) { unsigned int go(); } }
void my_function( unsigned int x ); // function prototype void main( void ) { unsigned int fred; my_function(unsigned int);// Inserted a call here }
OK. you are struggling with the basics of calling a function in 'C'.
You need to set aside your code, and concentrate just on the basic concept of calling a function - any function - and passing a parameter to it.
There is no point in trying to go any further before you have mastered this fundamental concept.
Hint: Look-up "formal" and "actual" parameters in your 'C' textbook.
Then try the exercise again:
Insert an appropriate call to my_function in the code below, passing fred as its parameter: then
void my_function( unsigned int x ); // function prototype void main( void ) { unsigned int fred; my_function(unsigned int fred);// Inserted a call here }
here the "actual" parameter is fred
and the "formal" parameter is x
Did you compile it? What did the compiler say?
What does your 'C' text book say about calling functions? Specifically, what should go inside the brackets?