CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with function!....HELP ME, please!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
micman
Guest







Problem with function!....HELP ME, please!
PostPosted: Thu Feb 27, 2003 2:08 am     Reply with quote

Hi all,
I have a problem with the funcion,
There are 3 function.
When code compiler, the error is "RECURSION NOT PERMITTED"
WHY?? and as I resolve it!
Thanks all!
the following code:

//-------------------------------------------------------------
//------ sf.c --------------
#include "sf.h"
int8 ch,modalita,sec;
const int8 id_mod3 = 0;
const int8 id_mod1 = 2;
const int8 id_mod2 = 4;

void main() {
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);

switch (ch)
{
case (id_mod1):
mod1();
break;
case (id_mod2):
mod2();
break;
case (id_mod3):
mod3();
break;
default:
output_low(PIN_A3);
output_low(PIN_A5);
output_d(0xBF);
output_low(PIN_A4);
}
}
void mod1() { //function 1

modalita = read_eeprom(5);
switch (modalita)
{
case (id_mod1):
sec = read_eeprom(1);
break;
case (id_mod2):
mod2();
break;
case (id_mod3):
mod3();
break;
default:
output_low(PIN_A3);
}
}
void mod2() { //function 2

modalita = read_eeprom(5);
switch (modalita)
{
case (id_mod1):
mod1();
break;
case (id_mod2):
sec = read_eeprom(2);
break;
case (id_mod3):
mod3();
break;
default:
output_low(PIN_A3);
}
}
void mod3() { ////function 3
output_low(PIN_A3);
output_low(PIN_A5);
output_d(0xBF);
output_low(PIN_A4);
}

//----------------------------------------------------------
// - sf.h -
#include <16F877.h>
#device *=16
#use delay(clock=20000000)
#fuses HS,PUT,BROWNOUT,NOWDT

void mod1(void);
void mod2(void);
void mod3(void);

//-----------------------------------------------------
___________________________
This message was ported from CCS's old forum
Original Post ID: 12160
Robert Holmer
Guest







Re: Problem with function!....HELP ME, please!
PostPosted: Thu Feb 27, 2003 3:51 am     Reply with quote

:=Hi all,
:=I have a problem with the funcion,
:=There are 3 function.
:=When code compiler, the error is "RECURSION NOT PERMITTED"
:=WHY?? and as I resolve it!
:=Thanks all!
:=the following code:

Ciao!
Recursion is not allowed with this compiler. MOD1 could call MOD2 and MOD2 could MOD1. Even if it is not going to happen the compiler does not accept it. If one of the calls is removed the compiler will accept the code.

Saluti,
Rob
___________________________
This message was ported from CCS's old forum
Original Post ID: 12161
micman
Guest







Re: Problem with function!....HELP ME, please!
PostPosted: Thu Feb 27, 2003 5:15 am     Reply with quote

Ciao Rob,
Thanks for answer, parli italiano?, I'm Italian

can possible use "goto ....."
example:

mod1(){
label1:
......
......
......
}

mod2(){
goto label1
}

Why "goto" only possible within function?

Thanks!



:=:=Hi all,
:=:=I have a problem with the funcion,
:=:=There are 3 function.
:=:=When code compiler, the error is "RECURSION NOT PERMITTED"
:=:=WHY?? and as I resolve it!
:=:=Thanks all!
:=:=the following code:
:=
:=Ciao!
:=Recursion is not allowed with this compiler. MOD1 could call MOD2 and MOD2 could MOD1. Even if it is not going to happen the compiler does not accept it. If one of the calls is removed the compiler will accept the code.
:=
:=Saluti,
:=Rob
___________________________
This message was ported from CCS's old forum
Original Post ID: 12164
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group