View previous topic :: View next topic |
Author |
Message |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 221
|
I am also having problems with function transitions. |
Posted: Mon Jan 18, 2021 4:06 am |
|
|
CCS C 5.99
MCU 33EP512GM710
crystal 16MHZ clock 120MHZ
I created functions as I have described. But when it is in function 2, I want to pass to function 1. It is giving error. Why is it doing this? How can I fix.
ERROR : Line 1165(1,2): Recursion not permitted [Table_Configuration]
for example;
Code: |
void func1();
void func2();
void func3();
void func3()
{
}
void func2()
{
if(press == TRUE)
func1();
}
void func1()
{
}
void main(void)
{
while(TRUE)
{
}
} |
_________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Mon Jan 18, 2021 5:15 am |
|
|
What you post, compiles happily.
Recursion, is a function calling itself. You would get that error, if (for
example) func1, then called func2(). |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Jan 18, 2021 5:38 am |
|
|
re: Recursion not permitted
The best, the very, very BEST real World example of 'recursion' I know , was when Bell Canada first offered 'call forwarding', something everyone takes for granted now. It was only in use about 2 weeks when the ENTIRE Toronto-Hamilton long distance system was shut down. NOBODY could make a call ! The problem was that EVERY pair of wires was in use !
Turns out some guy call forwarded his Hamilton home number to his Toronto office number. Before he left Toronto, he call forwarded his office number to his home number. Sounds OK, right ? What happened was ONE call got the Bell computers to keep taking phone lines to get the call from Hamilton to Toronto to Hamilton to Toronto to .......... until the entire system crashed. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Mon Jan 18, 2021 7:43 am |
|
|
Also, possibly worth saying that for the 16bit PIC's (where the stack is used
for variables as well as return addresses), it is technically possible to have
recursion used. There is a preprocessor directive #RECURSIVE, that
allows this for a single function. However this while working a few compiler
versions ago, does not work on the current compilers, and it involves
significant care, since otherwise a problem similar to the one Jay describes,
can apply to the stack.... |
|
|
|