Go to Post Luck *good or bad* and opportunity will always affect what happens to teams. - Brian C [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 09-02-2004, 18:28
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: How to measure execution time? And code size?

Quote:
Originally Posted by gnormhurst
Can someone describe a simple way to measure how much of the 26 ms time budget is being used? As I add code I would like to know how close I am coming to the limit.

Also, how do I know how close I am to the memory limits for code and data?

Thanks all,
Norm
I wouldn't worry too much about the 26 ms. If your code starts running over, then simply write some timer based code, that automatically sunchs w/the master provessor at least every 26ms. Use a backbuffering system, where you keep two copies of your data to send, a "im still working on this data" copy and a "this data is ready to send off" copy". You have a timer interrupt based function that is called every 25 ms or so that sends of the completed set of data automatically. When you have new data, you swap out the two sets. Take as much time as you want processign and don't worry about the 26ms. I would recommend you try to keep things under 26 ms, but if you can't then the above will work just fine. The way we measure the 26 ms time is by pulsing one of the IO lines each tiem data is sent off. That line is hooked up to a frequency counter. Thats the easiest wya if you have a frequency counter, or at the very least an oscilliscope.
__________________
1139 Alumni
  #17   Spotlight this post!  
Unread 17-02-2004, 00:43
WillyC's Avatar
WillyC WillyC is offline
"handy"
#1347
Team Role: Engineer
 
Join Date: Jan 2004
Location: Ottawa, Canada
Posts: 29
WillyC is on a distinguished road
Re: How to measure execution time? And code size?

Quote:
Originally Posted by Mark McLeod
A memory map can be generated by MPLAB whenever you compile your code. You have to turn it on by going to Project -> Build Options... -> Project then click on the "MPLINK Linker" tab, then click on "Generater map file". After you build your project look in the project directory for a text file ending in ".map" just a little way down the file it will have a section that looks like:
Code:
                              Program Memory Usage 
                               Start         End      
                           ---------   ---------      
                            0x000800    0x000837      
                            0x0008d4    0x0033d8      
                            0x0033da    0x003511      
                            0x300000    0x30000d      
            11395 out of 33816 program addresses used, program memory utilization is 33%
This gives you the program or rom space used. For the data or ram space it's a little harder. After the section above all space used will be listed by address. You'll see your familiar variables listed. You have to check the maximum addresses used by the data portion of your code.
Code:
e.g.,
    I   0x0007b7       data     static C:\mcc18\Projects\FrcCode\FrcCode\ifi_library.c
count   0x0007b8       data     static C:\mcc18\Projects\FrcCode\FrcCode\ifi_library.c
 temp   0x0007b9       data     static C:\mcc18\Projects\FrcCode\FrcCode\ifi_library.c
Thanks for this info Mark! This is helpful. I've just been looking at the .map file for my latest build and trying to calculate how much RAM I'm using up. I looked in the .map file in the section where it's sorted by address and noticed something interesting:

Code:
                              Symbols - Sorted by Address
                     Name    Address   Location    Storage File                     
                ---------  ---------  ---------  --------- ---------                
__tmp_0   0x000000     data     static D:\Code\Comp\v1\ifi_utilities.c
...
nullStr   0x0007da        data     extern D:\Code\Comp\v1\printf_lib.c
RCSTA2   0x000f6b      data     extern C:\FIRST\SRC\PROC\p18f8520.asm
...
TOSU   0x000fff          data     extern C:\FIRST\SRC\PROC\p18f8520.asm
I put the "..." in there to condense the info. But the interesting thing is the transition from C variables to assembly variables. The C variables occupy 2010 bytes of memory (0x000000 up to 0x0007da). Then there's a bunch of empty space from 0x0007db on up to 0x000f6a, and then the assembly variables occupy 0x000f6b up to 0x000fff. There are 4095 (FFF) bytes of RAM available in total, but it looks like all the IFI assembly defs and unions occupy the last 148 bytes from 0x000f6b up to 0x000fff.

To truly measure how many bytes you're using, you have to take the hex difference between the first assembly variable address (in all cases I think this will be 0x000f6b) and the last C variable address (in my case 0x0007da). Convert this number to decimal and subtract it from 4095 and the result is how many bytes of RAM your code uses.

It's also worth keeping in mind then that we really have 3946 bytes (up to 0x000f6a) of useable RAM since the IFI assembly stuff reserves the last 148 bytes. It will be hard to use that much RAM, but it's still worth noting.

Last edited by WillyC : 17-02-2004 at 00:52.
  #18   Spotlight this post!  
Unread 17-02-2004, 08:06
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,906
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: How to measure execution time? And code size?

Another interesting file to take a look at is "18f8520user.lkr"

It's a script for the linker blocking off PIC memory. A bunch of the space is listed as PROTECTED and the highest unprotected address is END=0x7F3

__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Interrupt timer, executing code asap? SeanCassidy Programming 10 07-03-2004 01:47
Actual execution time measurement Dan Technical Discussion 5 24-03-2003 11:36
Autonomous Code From Experience EbonySeraphim Programming 7 14-03-2003 21:56
Ok one problem cantwell03 Programming 3 13-02-2003 07:28
Solution to Timing Loops Steven Carmain Programming 39 10-02-2003 13:33


All times are GMT -5. The time now is 03:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi