Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] stack overflow executing call instruction in pic16f877a in proteus

Status
Not open for further replies.

Jaffer Alfahdawi

Newbie level 3
Joined
Apr 5, 2014
Messages
3
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Activity points
21
When i try to simulate with proteus, i get stack overflow error. I've used 9 if statements, when I remove 1, the simulation starts to work.

I've attached both the mikroc code and proteus files.

Any help would be greatly appreciated.:smile:
 

Attachments

  • mikroc code.rar
    56.8 KB · Views: 108
  • proteus file.rar
    62.4 KB · Views: 94

I can't test your code as it is missing .mcppi file. Is it mikroC code or mikroC PRO code? Are you using LCD? If yes, where are the LCD defines?

Array used for IntToStr() conversions like ambformat[] should have a minimum 17 bytes like ambformat[17].

You can't use -ve or 0 value for LCD row or column.

Lcd_Out(2, -3, ambformat);
 

to be exact, i have mikroC v8.2.0.0 and proteus v7.1, yes i am using LCD, this piece of code defines the LCD "Lcd_Init(&PORTB); // Initialize LCD connected to PORTB" which is on line 31 of the code. and why should array have minumum of 17 bytes?. i had to use -ve for LCD row and column, because that's the only way i got it to display temperatures properly.

Thanks

- - - Updated - - -

also i'm using the default pins for the LCD to connect to the microcontroller which i found in mikroc library.
 

As the stack is only 8 levels deep on the 16f877a I imagine that it has something to do with your problem!! The C compiler uses 1 level of the stack for every nested If statement.
 

How can i fix the problem do you think?
 
  • Like
Reactions: habte

    habte

    Points: 2
    Helpful Answer Positive Rating
How can i fix the problem do you think?

This is a limitation of the processor, change your program so that you don't use more than 8 nested IF's.
 
  • Like
Reactions: habte

    habte

    Points: 2
    Helpful Answer Positive Rating
The error explanation is plurally wrong.
- There are no nested if statements in the code, neither multiple call levels.
- If statements don't use the stack

As already mentioned, there are most likely other problems in the code like string overflow. I don't see where the code crashes, I don't use mikroC and can't check it. Does mikroC generate *.cof debug files? With it's help, we could trace code execution in Proteus or MPLAB.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top