NXC command FreeMemory()
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
NXC command FreeMemory()
Does the FreeMemory() command return the number of bytes in RAM that are available? If so, is there a command that returns the amount of available flash? Thanks.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC command FreeMemory()
Now, I'm not a NXC programmer but even I know how to use the search function over at the NXC help page (http://bricxcc.sourceforge.net/nbc/nxcd ... index.html). Type in 'freememory' and you'll get a great explanation and a sample program. Try it! When I tried to search for 'flash' it didn't come up with anything. Someone with more NXC experience will be able to explain better.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC command FreeMemory()
As I said, I know you aren't, but (as I also already said), the search doesn't work for me.
Edit: I figured it out, but it looks like it is for flash, not RAM.
I would like to know how to read both, so if you know how, please tell me.
Edit: I figured it out, but it looks like it is for flash, not RAM.
I would like to know how to read both, so if you know how, please tell me.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC command FreeMemory()
There isn't any way provided by the standard NXT or enhanced NBC/NXC firmwares to find out how much RAM is available.
I would encourage you to show what you have figured out on your own by using the help and guide when you post a question. It will help other newcomers to NXC (and other programming languages) learn "how to fish" as it were.
John Hansen
I would encourage you to show what you have figured out on your own by using the help and guide when you post a question. It will help other newcomers to NXC (and other programming languages) learn "how to fish" as it were.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC command FreeMemory()
So basically, a program can crash because the NXT was overloaded, but there is no way to detect that ahead of time?
So, just to confirm, the command is for reading the remaining flash, and it is the number of bytes remaining?
I'll try to remember to post what I already learned and tried when I ask questions in the future. Thanks for answering.
So, just to confirm, the command is for reading the remaining flash, and it is the number of bytes remaining?
I'll try to remember to post what I already learned and tried when I ask questions in the future. Thanks for answering.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC command FreeMemory()
First search result in Google:
- Xander
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Re: NXC command FreeMemory()
I will look into adding the ability to check how much RAM is available in a running program to the enhanced NBC/NXC firmware. I'll also look into exposing the "compact memory" option that the firmware has so that it can be executed manually by a running program. It is supposed to do that automatically whenever you try to allocate more memory for an array but it might be worth having the ability to do it on demand.mattallen37 wrote:So basically, a program can crash because the NXT was overloaded, but there is no way to detect that ahead of time?
So, just to confirm, the command is for reading the remaining flash, and it is the number of bytes remaining?
As the help files state, FreeMemory returns the number of bytes of flash memory that are free.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC command FreeMemory()
So, why does it return numbers no more than 106.644 kB? Does the firmware REALLY take up over half the flash? The AT91SAM7S256 has 256 kB of flash, so if I am only seeing less than half that, what is using up all the rest? I know that I have the program to read that number on it, but that only exists of the following. This small program can't take up much space.
Edit: the compiled program is 340 bytes, so REALLY small.
Code: Select all
task main()
{
NumOut(0, LCD_LINE1,FreeMemory()); //106644 bytes is the MAX with this program
while(true);
}
Edit: the compiled program is 340 bytes, so REALLY small.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC command FreeMemory()
The firmware is indeed just under 128K, the max limit of the IAR workbench for ARM (free, size limited version).
- Xander
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC command FreeMemory()
Then where did the rest go?
256000 (total)
- 128000 (FW)
- 000340 (program)
- 106644 (remaining)
=022016 bytes that are... lost? 22kB is a significant amount when talking about the NXT, and the programs.
256000 (total)
- 128000 (FW)
- 000340 (program)
- 106644 (remaining)
=022016 bytes that are... lost? 22kB is a significant amount when talking about the NXT, and the programs.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: No registered users and 5 guests