Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

a question about PICs

Status
Not open for further replies.

samcheetah

New Member
im starting out with PICs so there are alot of questions in my mind about them. plz help me out.

i want to know that if i have an ASM file for a program can i know what size it will occupy in the PIC. i am asking this because i saw a great program written for the '877. i believe that the '877 was used because of its bigger memory space. but i want to know that if that program will fit into a '628 or not.

i know that there could be other reasons why the programmer chose the '877. but anyway this question came into my mind and i thought someone here will give me an answer
 
I believe if you convert your ASM code to hex, the size of the hex file will be the amount of program memory taken up on the PIC.
 
dak246 said:
I believe if you convert your ASM code to hex, the size of the hex file will be the amount of program memory taken up on the PIC.

wrong! An intel hex file stores the data as ascii and it also contains address information and a checksum, all data that doesn't end up in the pic...

In fact, a 10K hex file ends up as only using 1K5 in the pic

samcheetah, MPLAB allows you to generate a map file on compile (search the help to see how to turn it on). A map file contains memory information such as the amount of mem the prog will use
 
You can also assemble the code for an 877, then load it into a PIC programmer - WinPicProg (among others) allows you to examine the data as it's going to be blown in the PIC - so you can easily see how big it is.

Quite often the 877 is chosen for it's hardware extras, rather than it's memory size - I always use the larger PIC's, even when memory requirements don't need it - for instance, I always buy the 16F628, rather than the 16F627 - although most projects probably fit in the 627 anyway.
 
samcheetah said:
i want to know that if i have an ASM file for a program can i know what size it will occupy in the PIC. i am asking this because i saw a great program written for the '877. i believe that the '877 was used because of its bigger memory space. but i want to know that if that program will fit into a '628 or not.

If you assemble the ASM file using MPASM, the resulting LST file wiil give you all the information on program space usage. The ff. is a sample portion of the info:

Code:
MEMORY USAGE MAP ('X' = Used,  '-' = Unused)

1000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
1040 : XXXXXXXXXXXXXXXX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XX
2100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXX---- ---------------- ----------------
2140 : -----XXX-------- ---------------- ---------------- XX-------XX-----

All other memory blocks unused.

Program Memory Bytes Used:  5123
Program Memory Bytes Free: 27645

Because they belong to the same PIC16 family, the '628 will use the same amount of code space as any program written for the '877, assuming you are successful in converting the program from the '877 to the '628.

One advice to allow for easy portability and convertion from one PIC processor to another is to use Microchip's predefined constants by including the correct "INC" file for the processor used. That is, "PIC16F877.INC" for '877s and "PIC16F628.INC" for the '628. The first step to converting is simply changing the include file.
 
After you build your program in MPLAB you can simply click VIEW/PROGRAM MEMORY. Scroll down to where your last instruction is and read off what memory location it is in.

-Bill
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top