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.

PIC program size and hex file size confusion

Status
Not open for further replies.

sonar_abhi

New Member
Hello guys!

I am a newbie in PIC programming. I have written a simple program and compiled it in mikroC selecting PIC16F877A as the microcontroller. The generated hex file is of 5kB size. But in the mikroC compiler, the compiler shows the following messages:

Used RAM (bytes): 2 (1%) Free RAM (bytes): 350 (99%)
Used ROM (program words): 57 (1%) Free ROM (program words): 8135 (99%)

Essentially my program size on the chip is only 57 words ~ 0.1kB, but when I build it, the generated hex file is 5kB in size.

The funny part is that I am able to burn the 5kB hex file in PIC16f72 which has a program memory of 2kB

Can anybody please explain what is going on?

Regards,

Ace
 
First the program memory on the PIC is 14 bits long so you need two bytes to store each program memory location (Two bits will not be used as two bytes is 16 bits.) The next thing is that in a HEX file each nibble (4 bits) is represented by an ASCII character. So now 4 bytes are required to hold each program location. Also there is address information and checksums in the hex file which make it even larger. If you need more detail try Googleing "hex file structure" I can't remember the details of the structure as it is many years since I wrote any code to create hex files from binary files.

Les.
 
hex file structure
:=start
10=how long the line or how much data 10hex=16
0000=address where the data goes
00=instruction, end of file or there is more data coming, etc
data, for a 8 bit computer 56= one instruction, for your PIC 3456=one instruction
90=the last two is a check sum.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top