Error message in MikroC "Not enough RAM for call stack __Lib_Delays.c" - Page 1
Forum section: electronics / general

author: asadulhuq
author_rank: Contributor
timestamp: September 03, 2020, 08:15:31 am
content: 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 called2 times or morein 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();}

author: JPortici
author_rank: Super Contributor
timestamp: September 03, 2020, 06:02:35 pm
content: 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:and if you could use  tagsthe 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..

author: asadulhuq
author_rank: Contributor
timestamp: September 04, 2020, 02:46:14 am
content: Thanks. The code follows-void my_delay_500() {Delay_ms(500);}Thanks again.

author: greenpossum
author_rank: Frequent Contributor
timestamp: September 04, 2020, 03:32:32 am
content: To avoid another level of subroutine call you could define my_delay_500 as a macro. E.g.Code:#define my_delay_500() Delay_ms(500)

author: asadulhuq
author_rank: Contributor
timestamp: September 04, 2020, 03:53:51 am
content: Thanks. I will try it now.

author: asadulhuq
author_rank: Contributor
timestamp: September 04, 2020, 05:15:35 am
content: 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 eepromif (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.cThanks again.Please see the attached screen shots.

author: greenpossum
author_rank: Frequent Contributor
timestamp: September 04, 2020, 05:21:08 am
content: Delay is not Dealy.

author: asadulhuq
author_rank: Contributor
timestamp: September 04, 2020, 05:24:21 am
content: I am so sorry!

author: JPortici
author_rank: Super Contributor
timestamp: September 04, 2020, 06:43:15 am
content: 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

author: asadulhuq
author_rank: Contributor
timestamp: September 05, 2020, 06:25:03 am
content: 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.