Author Topic: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"  (Read 3007 times)

0 Members and 1 Guest are viewing this topic.

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Dear All,

Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c". This occurs when following beep() function containing Sound_Play routine is called 2 times or more in main(). One time calling is okay. I am using PIC16F628A and MikroC Pro for pic compiler. May be the problem is related with the delay routines. I use a good number of delays in my code.

Any hint that might solve the problem, is welcome. Thanks.
 
MikroC Pro for PIC code:

void beep() {
 Sound_Init (&PORTA, 2);
 Sound_Play(600,500);
 my_delay_500();
 Sound_Play(800,500);
 my_delay_500();
 }
« Last Edit: September 03, 2020, 03:15:46 pm by asadulhuq »
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #1 on: September 03, 2020, 06:02:35 pm »
Good, you edited the OP adding the PIC you are using.

It's been a long time since i ditched mikroC for better compilers (i do consider XC8 to be better... i've used it since version 1.0. and screw libraries, i write my own anyways) but i'll try my best.

Would you mind sharing the code for my_delay_500?

Code: [Select]
and if you could use [code] tags
the message about RAM for call stack sound strange, because 8bit PICs have a dedicated hardware call stack, it's not in RAM.  The problem is of course that you can't exceed the depth of the call stack so let's see the code for your delay routine..
« Last Edit: September 03, 2020, 06:05:04 pm by JPortici »
 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #2 on: September 04, 2020, 02:46:14 am »
Thanks. The code follows-

void my_delay_500() {
 Delay_ms(500);
}
Thanks again.
 

Offline greenpossum

  • Frequent Contributor
  • **
  • Posts: 408
  • Country: au
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #3 on: September 04, 2020, 03:32:32 am »
To avoid another level of subroutine call you could define my_delay_500 as a macro. E.g.

Code: [Select]
#define my_delay_500() Delay_ms(500)
 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #4 on: September 04, 2020, 03:53:51 am »
Thanks. I will try it now.
 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #5 on: September 04, 2020, 05:15:35 am »
I am trying to use your advice to code time delay in my timer.c. However, there come error messages. Please see attached figures. May be I am making some silly mistakes. Please note I am new to microcontroller programming. Any modifications or corrections in my code do I need? Thanks.
My code segments:

#define my_delay_30() Dealy_ms(30)
#define my_delay_50() Dealy_ms(50)
#define my_delay_500() Dealy_ms(500)
#define my_debounce() Delay_ms(250)

/////

void Read_EEPROM() {                      ////Load from eeprom
 if (EEPROM_Read(0x16) == 1){
  my_delay_30();
  minutes = EEPROM_Read(0x11);
  my_delay_30();
  seconds = EEPROM_Read(0x12);
  my_delay_30();
 }
}

error:

Line-80 Undeclared identifier 'Dealy_ms' in expression Timer.c
Thanks again.

Please see the attached screen shots.
« Last Edit: September 04, 2020, 05:19:24 am by asadulhuq »
 

Offline greenpossum

  • Frequent Contributor
  • **
  • Posts: 408
  • Country: au
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #6 on: September 04, 2020, 05:21:08 am »
Delay is not Dealy.
 
The following users thanked this post: asadulhuq

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #7 on: September 04, 2020, 05:24:21 am »
I am so sorry!
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #8 on: September 04, 2020, 06:43:15 am »
as i suspected, you are calling delay_ms in your delay function.
why not just call delay_ms directly?
or use a macro as suggested
 
The following users thanked this post: asadulhuq

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c"
« Reply #9 on: September 05, 2020, 06:25:03 am »
Thanks for suggestions. The error message do appear in some functions when I call beep() . However, I have avoided those situations at least for this time. The said function (beep()) has some thing to do with the Delay_ms() routine and also with the interrupt at the same time. I have to study more. I learn a lot from you. Thanks again.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf