Pgm size of 18f4520

Status
Not open for further replies.

Urahara

Member
Hi

Some queries with regards to the program memory size of a 18f4520 I am currently learning with.

After compiling a demo C pgm with the C18 compiler, Windows File Explorer reported the hex file as 18KB. 18KB is slightly more than half of the 32KB program size on the chip!! And this is just a demo pgm!

Went into PICkit2. The pgm ended on byte 18A8 which is 6312 bytes after which FFFF appeared. Assumed that meant the hex pgm is actually 6312 bytes rather than 18KB as reported by Windows?

1) So what is the actual size of the pgm?
2) Why the discrepancy? Or am I reading and interpreting the info wrongly?
3) How much can 32KB of the 18f4520 do ? If I want to hv hv a pgm that :
- read temperature using a LM35
- get inputs from a 4x4 keypad
- from the inputs, apply some formulae to get some results
- displays all outputs on a LCD module
- count down and count up with beeping
can 32KB of pgm space cut it?

Am quite new to this so all comments welcome.

Thks!
-
 
A HEX file is an ASCII representation of a binary file, and includes lots of extra information the programmer needs to locate the program correctly. So a HEX file is a number of times larger than the actual program itself.

There's also a .LST file created, have a read of that, it tells you how much memory is been used (amongst much more useful information).

32K is a huge amount of memory, your requirements could probably fit in the 2K space of a 16F628 if written in assembler.

There's rarely any need to use floating point maths, and doing so takes considerable room, and runs relatively slowly - however the huge space you have, and great speed of the processor means you can ignore such problems.
 
On windows you were looking at the file size of a intel hex file. It is several times larger then the binary bits it represents. All C programs use a routine called C0 that does the required house keeping needed to setup the user program to run. Even the program "void main(void){}" will be as large as the C0 routine. The C18 compiler calls its C0 C018 and it is linked with your program. You can see it in the edit window after you do a reset during debug.

If you are working in MPLAB look at the memory gauge under view to see the actual bytes used. That is the easiest way to find it.

Yes you can do all that and much more in 32K bytes.

I need to point out that you are talking about 32K bytes. Because each computer instruction uses a word the number of words can be more meaningful.

This chip has 16K words which is a large memory for a 8 bitter.
 
Nigel.
The last time I answered a similar question about memory size you chewed me a new one for talking about bytes instead of words.
 
Nigel.
The last time I answered a similar question about memory size you chewed me a new one for talking about bytes instead of words.

I didn't actually mention either!

Without looking it up I've no idea if the 32K referred to bytes or words, but it makes no difference - it's still loads of space.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…