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
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?
"here the 'actual' parameter is fred and the 'formal' parameter is x"
Yes - good!
Now, what should go inside the brackets in the call to the function?
as far as this e.g. concern the value assigned to fred is going to used in the my_function.i.e. it passing to through the basket and used by the function
"the value assigned to fred is going to used in the my_function"
Yes, so if you want the value of 'fred' to be passed through to the function, what do you put inside the brackets in the function call?
Hint: the type of 'fred' has already been defined in the line
unsigned int fred;
So the compiler already knows what type 'fred' is - you don't have to specify it again, do you...?
void my_function( unsigned int x ); // function prototype void main( void ) { unsigned int fred; my_function(fred);// it is ok now }
but now it genrates warnning, and not going to execute the which executes before the change's
while(1) { unsigned int go();this function of the code }
WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
Correct!
Do you now understand what the problem was?
"but now it genrates warnning"
That is actually progress! Before, it didn't even compile - now it does compile, but gives this warning.
You need to post the full text of the message (remember: copy-and-paste) - it will include the name of the segment that is "uncalled"
her is the full code with warnning
#include<reg52.h> #include<define.h> #include<intrins.h> /*function declaration*/ void blink(void); void disp_wait(void); void disp_inc_wait(void); void sft_wait(void); void disp(unsigned int a); void blink(void); unsigned int go (void); /*************************/ unsigned char number_code[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned int i,j,k,l,a; unsigned int sft;// = 1; /* interrupt setting (routine)*/ void TMR_0(void) interrupt 1 { TF0 = 0; TR0 = 0; TH0 = 0xAA; disp(a); 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(); DECOD1 = 1;/*** 7-segment 2nd display *******/ DECOD2 = 0; DECOD3 = 0; P0 = number_code[j]; if(sft != 2) {disp_wait();} blink(); DECOD1 = 0;/* 7-segment 3rd display ****/ DECOD2 = 1; DECOD3 = 0; P0 = number_code[k]; if(sft != 3) {disp_wait();} blink(); DECOD1 = 1;/** 7-segment 4th display *****/ DECOD2 = 1; DECOD3 = 0; P0 = number_code[l]; if(sft != 4) {disp_wait();} blink(); } /***dly routine's*************/ void disp_wait() { unsigned int w1 = 0; unsigned int w2 = 0; for(w1 = 1;w1<=2;w1++) { for(w2 = 1;w2<=200;w2++) {} } } void disp_inc_wait() { unsigned int w1 = 0; unsigned int w2 = 0; for(w2 = 1;w2 <=60;w2++) { for(w1 = 1;w1 <=800;w1++) { _nop_(); } } } void sft_wait() { unsigned int w1 = 0; unsigned int w2 = 0; for(w2 = 1;w2 <=100;w2++) { for(w1 = 1;w1 <=800;w1++) {_nop_();} } } /****blink char(dly)******/ void blink() { unsigned int w1 = 0; unsigned int w2 = 0; for(w2 = 1; w2<=20; w2++) { sft_wait(); } } /****** 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();WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS } } unsigned int go() { /*shift key press identification ****/ if(KEY2_SFT == 0) { sft++; sft_wait(); KEY2_SFT = 1; if(sft > 4) {sft = 1;} } /* opration on shift char ***/ switch(sft) { case 1: /****** 7-segment 1st *******/ if(KEY1_INC == 0) { i++; if(i > 9) {i = 0;} disp_inc_wait(); KEY1_INC = 1; } break; case 2: if(KEY1_INC == 0) /* 7-segment 2nd */ { j++; if(j > 9) {j = 0;} disp_inc_wait(); KEY1_INC = 1; } break; case 3: if(KEY1_INC == 0)/* 7-segment 3rd ***/ { k++; if(k > 9) {k = 0;} disp_inc_wait(); KEY1_INC = 1; } break; case 4: if(KEY1_INC == 0)/* 7-segment 4th */ { l++; if(l > 9) {l = 0;} disp_inc_wait(); KEY1_INC = 1; } break; } a = sft; return(a); }
Why do you think it's associated with that particular line?
This is a Linker warning - that's why it begins with an 'L' It is not related to a specific 'C' source line!
The full text of the message looks like this: http://www.keil.com/support/man/docs/lx51/lx51_l16.htm
Or this: http://www.keil.com/support/man/docs/bl51/bl51_l16.htm
You have omitted to post the important bit - which is the segment-name
The segment-name tells you what it is that the Linker thinks is uncalled...
i m very very thank full to you for guiding me. as problem is solved fully(no error by changing the type defn and warnning by giving or alloting the returned value to other variable and from that varible the value is collected at the other end ) this help's me alot but not able to give the output as i required i have to think in other way again thank's for u r help