In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Sparks-R-Fun wrote: I will offer a few comemnts. [CODE] IRC_CAL IRC_SLOW 'dunno if needed, used to add startup overhead [/CODE] This command is used to trim the internal resonator circuit, usually trying to get it somewhat close to 4MHz. This calibration occurs only at the time the device is programmed. Here you have selected to have this trimmed to run as slowly as possible. Since you are using an external resonator or oscillator, this command is not needed. [BLUE][B]Maximizing Global Variable Space[/B][/BLUE] Some tips for maximizing global variable space include making global variables as generic, temporary and reusable as possible and, of course, making the most of variable arrays. As an example of reusing global variables, unless I have overlooked something, you presently use word variables pWidth0 and pWidth1 exclusively to determine the length of the IR pulse. (I do see where you reuse pWidth0 elsewhere.) To me these two variables look like good candidates for temporary variables. You might try using temporary variables for pWidth0 and pWidth1. It should save you an extra four global bytes, unless I have missed something. (That is quite possible.) Also, it looks like your bit variables and your "theDug" and "dug" byte variables can easily be placed inside an array. This will save you three more global bytes bringing the total of freed global bytes up to seven, if everything works as I have described. This should give you a good start toward better optimizing your global variable space. I will leave it up to you or others to notice further opportunities for optimization. These are things that I noticed in addition to what has already been said, not in place of them. The following variable declarations illustrate what I have outlined above. [CODE] ' -----[ Variables ]------------------------------------------------------- ' tach vars rpm VAR WORD dividendMSW VAR WORD dividendLSW VAR WORD 'wanna be local variables tmpW1 VAR Word tmpW2 VAR Word tmpB1 VAR Byte tmpB2 VAR Byte [RED]pWidth0 VAR tmpW1 ' Variable "pWidth0" will use the same memory space as variable "tmpW1". pWidth1 VAR tmpW2 ' Variable "pWidth1" will use the same memory space as variable "tmpW2". Tach_Array VAR BYTE(16) ' Create a 16-byte array to hold tach variables. overflow VAR Tach_Array(0).0 ' Uses byte 0, bit 0 of Tach_Array. doneBit VAR Tach_Array(0).1 ' Uses byte 0, bit 1 of Tach_Array. theDig VAR Tach_Array(1) ' Uses byte 1 of Tach_Array. dug VAR Tach_Array(2) ' Uses byte 2 of Tach_Array.[/RED] [/CODE] This also caught my eye. [CODE] pwidth0=10 'how many times to show rpm to display. I need to add banking, recycling this var for now, locals please god! pwidth0= pwidth0 << 2 '(<< 2 is just *4)this number has to be a multiple of 4 since we need to loop 4 times to get 4 digits [/CODE] It seems to me that it would be shorter to just say [CODE] pWidth0 = 40 [/CODE]Or better yet, consider using a constant that is declared at the top of your program listing. (I am talking PURELY for OPTIMIZATION sake here! Since you have plenty of program space you might prefer to leave it in place since, as you aptly point out, using the rotate ensures the value is a multiple of four.) Thanks for opening your code to scrutiny. I enjoy looking at other people's code! - Sparks ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=230849#m231033 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)