PDA

View Full Version : Matching PIC memory and program size?



manxman
- 6th August 2006, 22:04
I need help in understanding how to select a PIC with the flash program memory size to accommodate my PBP-compiled programs.

For example, Microcode Studio tells me that one of my small programs for the 16F877 compiles to 377 words, while Windows Explorer gives the HEX file size as 2.14K. Once the project is completed, I want to choose a device with minimal size and cost to fit the code.

In general, how do you understand each of these memory sizes, and then choose a suitable PIC device?

Charles Linquis
- 7th August 2006, 00:38
The number you get from Microcode Studio is the more accurate. The .HEX file is in Intel Hex format, which is an ASCII representation of the binary source.
A 512 byte or 1K byte PIC should easily hold your code.

If you want to find out what that .HEX file really contains (as well as the load addresses of the code), you can decode the .HEX file according to the rules given at:

www.cs.net/lucid/intel.htm

manxman
- 7th August 2006, 10:32
Thanks for the clues, Charles.

However, I am still a little bit confused. For example, suppose I change to a 16F676, which the data sheet says has "1024 Flash Words" of program space. Do these WORDS equate with the WORDS given by Microcode Studio?

It is a pity that this is not properly explained in any of the MCS or PBP documentation and that MCS (or my MEL chip programmer) does not give the % space remaining or used in the device selected.

sayzer
- 7th August 2006, 11:12
Do these WORDS equate with the WORDS given by Microcode Studio?

Yes, pls refer to the picture.

The word size of a PIC should match (or stay lower) then the word size that your compiler compiles for you.

http://img9.picsplace.to/img9/20/thumbs/628A_size.GIF (http://img9.picsplace.to/img.php?file=img9/20/628A_size.GIF)

manxman
- 7th August 2006, 15:14
Many thanks Sayzer and Charles for the final WORD (!). All clear now. I can now program a device until it (almost) bursts.

Corona
- 7th August 2006, 21:29
The word size of a PIC should match (or stay lower) then the word size that your compiler compiles for you. Methinks you mean the capacity of the PIC should be HIGHER than the compiled code size...in words :D

sayzer
- 8th August 2006, 07:23
Yes, actually I stated it from the other side.

You are right Corona.

PIC capacity should be higher.

Corona
- 8th August 2006, 19:26
no problem

I've found that soon after using the MIN / MAX PICBasic functions, I get confused over Up/Down Right/Wrong myself :D

sayzer
- 9th August 2006, 08:02
Also take a look at this post here:

Word sizes for the same code but for different PICs are also different.


http://www.picbasic.co.uk/forum/showthread.php?t=3548