• AVR Freaks

Hot!Calculating the RAM usage

Author
iamnaveen685
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2018/09/18 07:44:02
  • Location: 0
  • Status: offline
2021/03/04 00:54:33 (permalink)
0

Calculating the RAM usage

Hi,
 
 
I want to calculate the stack usage, CPU usage and cpu usage at maximum load and size of stack memory in dspic33ev256gm104.how to do this things
 
thanks is advance
#1
JPortici
Super Member
  • Total Posts : 1327
  • Reward points : 0
  • Joined: 2012/11/17 06:27:45
  • Location: Grappaland
  • Status: online
Re: Calculating the RAM usage 2021/03/04 01:17:03 (permalink)
0
Are you using an RTOS? they usually provide functions to report CPU usage (how much time the CPU is not in the idle task) and some probide ways to calculate the amount of stack used statically. But i never had to do it, so it would be interesting to see how others approached this..
 
If you are not using an RTOS well the CPU usage is always 100%
#2
iamnaveen685
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2018/09/18 07:44:02
  • Location: 0
  • Status: offline
Re: Calculating the RAM usage 2021/03/04 02:59:43 (permalink)
0
Hi ,
 
thanks for the reply
 
We are running the system without the RTOS, so the load will be 100% ,
 
Regarding the calculation of the Stack usage, 
 
kindly anybody explain this
#3
du00000001
Just Some Member
  • Total Posts : 4145
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Calculating the RAM usage 2021/03/04 03:39:32 (permalink)
5 (2)
iamnaveen685
Hi ,
 
thanks for the reply
 
We are running the system without the RTOS, so the load will be 100% ,
 
Regarding the calculation of the Stack usage, 
 
kindly anybody explain this



Basically, you need to initialize the whole stack area with a pattern unlikely to be written during normal operation (prior starting the application software), then - after some time - check how much of the pattern is still untouched. As you may assume: the whole thing requires the use of a debugger.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#4
NKurzman
A Guy on the Net
  • Total Posts : 19185
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Calculating the RAM usage 2021/03/04 11:14:52 (permalink)
3 (1)
If you want to know when you program in not busy, you need to create a place for it to wait.
There is no way for the CPU to know if it is doing useful work.
 
You can google for how to check the Stack.
It usually involves filling the Stack with some value (0, 42, 99,0xFF, 0xDEADBEEF, ect)
Then the monitor routine will read the stack backwards until it finds a value that is not in the Fill.
 
There maybe some example in the Class B libraries.
#5
cirilo.b
Senior Member
  • Total Posts : 73
  • Reward points : 0
  • Joined: 2020/09/08 18:40:42
  • Location: 0
  • Status: offline
Re: Calculating the RAM usage 2021/03/04 18:22:39 (permalink)
0
You can get an estimate of stack use by using a regular interrupt (for example, if Timer 1 is being used as the system timer) to record the difference between the Stack Top and the Stack Pointer value.
#6
Jump to:
© 2021 APG vNext Commercial Version 4.5