Sonsivri

Electronics => Pic C Languages => Topic started by: sam_des on August 10, 2022, 04:49:19 04:49



Title: CCS PICC Stack Usage Report
Post by: sam_des on August 10, 2022, 04:49:19 04:49
Hi,

I am using PICs after a very long time. Also using CCS PICC(5.109) with MPLAB-X(6.0) just to get hang of it again.
Compiled a small project for PIC16F15386 successfully and it so far is running ok.
But looking at list file generated by compiler, I go this...
Code:

               ROM used:   1306 words (8%)
                           Largest free fragment is 2048
               RAM used:   84 (4%) at main() level
                           118 (6%) worst case
               Stack used: 0 locations
               Stack size: 16


There are actually 'CALL's present in the code, this summary simply doesn't report it.
Interesting thing is, there is also 1 interrupt enabled(TIMER0) which in turn in calling functions 2 level deep, even that isn't showing up in LST file summary.

The '.TRE' file also shows CALLs. Obviously mismatch between .TRE & .LST file summary.

Is it something to do with some MPLAB setting ? Or is it some bug with this particular version of PICC?

Thanks,
sam_des


Title: Re: CCS PICC Stack Usage Report
Post by: h0nk on August 10, 2022, 10:18:06 10:18

Hello sam_des,

8 bit PIC's use a hardware stack for CALL's and Interrupts.
The report of the compiler might reflect the usage of
"automatic variables", which are allocated on an emulated
software stack.



Best Regards


Title: Re: CCS PICC Stack Usage Report
Post by: sam_des on August 10, 2022, 03:03:27 15:03
Hello,

Quote
8 bit PIC's use a hardware stack for CALL's and Interrupts.

I am painfully aware of that.  :-X :'( 
As far as I know, the Stack Usage summary in LST file reports only the Hardware Stack usage.
The functions which compiler inlines or use GOTOs as optimization to save the hardware stack are marked as such in TRE file.


Quote
The report of the compiler might reflect the usage of
"automatic variables", which are allocated on an emulated
software stack.
I don't think this emulated stack or variable OVERLAYing as called by other compilers, for auto/param/return variables, have anything to do here.


And lastly, no matter what compiler does, INTERRUPT has to use at least 1 level of HARDWARE stack, isnt it?

Thanks again,
sam_des


Title: Re: CCS PICC Stack Usage Report
Post by: h0nk on August 10, 2022, 04:21:25 16:21
Hello sam_des,

> Stack size: 16

Is the Hardwarestack really 16 Levels deep?

I use XC8 only for 8 bit PIC's, so i am unaware of the software
stackof the PICC compiler.
This software stack would be used for "reentrant" functions in XC8.
Otherwise the compiler only allocates registers for variables.
This would obviously not work for reentrant functions.

For interrupts You should take a look in the section "Automatic Context Saving"
of the datasheet.

I took a look of the datasheet of a similar device (16F1508) and it seems the
hardwarestack now really can hold 16 entries.
I am afraid, i could not help further.


Best Regards