We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
in c51 i use function pointer : code void (*serial_tabel []) () ={ func_0, func_1, func_2, func_3,func_4 }; static void func_0 (){ strcpy(SPackData,"ngetit 0"); SendPack (); } static void func_1 (){ strcpy(SPackData,"ngetit 1"); SendPack (); } static void func_2 (){ strcpy(SPackData,"ngetit 2"); SendPack (); } static void func_3 (){ strcpy(SPackData,"ngetit 3"); SendPack (); } static void func_4 (){ data byte a,b,d; a = (byte) atoi(CMD_LOC[1]); b = (byte) atoi(CMD_LOC[2]); d = (byte) atoi(CMD_LOC[3]); SetBaseFrq(d); strcpy(SPackData,"i love you !"); SendPack (); } in func_4 () i get this warning : *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?SERIAL_CMD2 CALLER: ?PR?FUNC_4?SERIAL_CMD2 why ? what mean ? how reolve ?
It sounds like you have declared a table of function pointers in code space and some other variables in code space in the same file (SERIAL_CMD2.C). The error message
*** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?CO?SERIAL_CMD2 CALLER: ?PR?FUNC_4?SERIAL_CMD2
"There is an application note that covers everything you should know about function pointers in C51 because they are tricky." I've already told him that: http://www.8052.com/forum/read.phtml?id=32055&top=
I know. :-) Thanks, Jon
than Jon Ward ! i read this app note but no found any help about warning 13 have one sample app to solve this problem ? i see some topic and note in this site about function pointer but i think work function pointer in c51 not easy ! some of it have manualy edit file it very bad for programmer
C51 does not pass parameters using stack frames. That is what causes problem with function pointers. Application Note 129 explains everything you need to know about functions pointers and how to develop programs using them. If you only glance at the application note looking for an answer to the error, you will not find the answer. The application note is a wholistic solution--not just a band-aid. Jon
thanx Jon Ward i move all function pointer in new c source file this is way for solve problem occurce with using in c51 function pointer ? the my new file (fpointer.c) : extern void func_0 (); extern void func_1 (); extern void func_2 (); extern void func_3 (); extern void func_4 (); extern void Dfunc_0 (); extern void Dfunc_1 (); extern void Dfunc_2 (); code void (*serial_tabel []) () ={ func_0, func_1, func_2, func_3,func_4 }; code void (*DCMDF1 [])() = { Dfunc_0, Dfunc_1, Dfunc_2 };
"this is way for solve problem occurce with using in c51 function pointer?" As Jon said, this is the way to resolve the specific problem you are reporting here. However, you still need to carefully read & fully understand the references already cited - in order to avoid falling into any of the other pitfalls of functions pointers with C51! To recap, the Required Reading is: 1. Application Note 129: http://www.keil.com/appnotes/docs/apnt_129.asp 2. This knowledgebase article: http://www.keil.com/support/docs/210.htm A search of this forum for previous discussions of Function Pointers in C51 would also be a good idea!
hi andi: i read all app note and topic about function pointer in c51 but i think this not complete ! some of it have use manual edit before link is very bad and get many time then i not never use 1. some of it have i define FP (function pointer) in code i doit i get new erorr ! *** WARNING L13: RECURSIVE CALL TO SEGMENT SEGMENT: ?PR?SERIAL_DCMD1 CALLER: ?PR?DFUNC_1?SERIAL_DCMD1 after i move function pointer in new file problem resolve but now i write some code in one function and give this error i cry for this error :-(
"i read all app note and topic about function pointer in c51" If you've read all that, then you should now understand why function pointers are so difficult for any 'C' compiler targetted to the 8051 - it is due to a fundamental limitation of the underlying hardware architecture (viz, chronically limited stack space). When writing software for embedded systems, you always have to bear in mind the limitations of the target hardware. Is it really essential that you use function pointers? Considering the target architecture, and the inherent problems you've already seen, wouldn't another approach be more appropriate? Conversely, if function pointers really are absolutely essential, is this an appropriate target? Have you considered making your functions reentrant? It might help, but at a big cost in performance.