PDA

View Full Version : Code space needed with MPASM??



BrianT
- 7th September 2007, 00:23
I have a program that runs in a 16F877A and I want to replace the microcontroller with an 18F4550 to get more code space for extra features.

The 877A assembled with PM takes a code space of 6567 words.
The 877A assembled with MPASMWIN takes 6565 words.
The 18F4550 assembled with MPASMWIN takes 10950 bytes. (Does this mean 5,475 words or 10950 words??)

MCS+ reports program memory used for the 877A in words but MCS+ reports memory used in the 4550 in bytes. Do they really mean bytes?? I would have thought it meaningless to report the number of 16 bit program instructions needed in bytes.

How can I quickly tell if the 4550 program really takes 5475 or 10950 words of program memory?

Cheers
Brian

BrianT
- 7th September 2007, 01:08
Using the same program, I checked the .HEX file made by MPASMWIN for both the 877A and the 4550 micros. The .HEX for the 877A was 37K and the .HEX for the 4550 was 31K.

37 * 5475/6565 = 31 close enough.

I guess MCS+ really does report in BYTES used for program memory with some microcontrollers and in WORDS for others - watch out.

Brian

Jumper
- 7th September 2007, 02:12
If you want to change from a 877A to something bigger you should consider the 18F4620 since it shares the pinout. Just plug that PIC in the same place as the 877A and adjust the code for the PIC registers and you are up and running. It doesnt hurt either that it has bigger codespace than the 4550 unless USB is the extra feature you are looking for then you have to go for the 4550.


/me

BrianT
- 7th September 2007, 04:22
Good suggestion Jumper however I work at an Australian university, all of which have suffered savage government funding cuts over the last ten years. I have 100 of the 18F4550 from another department available and the project cost is already too high. The PCBs have been ordered and the 4550 is pin for pin except RC3 which is not used in this design.

I intend to make the 4620 the 'standard' microcontroller here as I can then retrofit numerous projects with extra features and relax about tight memory for future projects.


Brian

paul borgmeier
- 7th September 2007, 05:43
I guess MCS+ really does report in BYTES used for program memory with some microcontrollers and in WORDS for others - watch out.
Nothing random going on – see the datasheet for the PIC in question (usually the first table in the datasheet)

18F's have 16 bit wide instructions, which are reported as 2 bytes per 16 bit instruction.

16F's and lower have 14 (or 12) bit wide instructions, which are reported as 1 word per 14 (or 12) instruction.

Yes, you can divide the 18F byte count by 2 to roughly compare to the 16F family.

HTH

Jumper
- 7th September 2007, 10:24
Hi,

Why do you plan to pick the 18F4620 as you future standard PIC? I would really consider choosing the 4550 for all things instead. Sure, you will get half as much memory as the 4620 but that would force the students to keep the code short and efficient. (and the option to in worst case plug in a 4620 to save the project)


I think USB or Ethernet support is more the future and that would allow the students to make neat stuff and connect to other devices.

Looking at the pricing at Microchips webpage you can see that the 4550 is around 4 USD, 4620 is 4.2 USD and PIC18F67J60 is 3.5 USD.... they are more or less the same price.

Looking at performance the PIC18F67J60 stands out. Ethernet support, 128 kB Flash (2 times 4620 and 4 times 4550) so if you are looking for maximum memory for a low cost this is your choice and cheaper than the other two. and it has PBP support :-) the only downside I can think of is that it is a 64 pin smd package....

/me