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.

to many lines of code :| Sheit...

Status
Not open for further replies.

ManTic

New Member
Hey :)

I'm rather new with PICs and C, and I just found out that the program I wrote for my PIC16F877 is about 10-12kb big (depending of the amount of writing I do to the LCD)... And the PIC can only hold 8kb

I am using SourceBoost's C++ compiler...

Some of my methods aren't that clever, because the compiler has some limitations (compared to some code i saw compiled with IAR's C compiler - sourceBoost couldn't compile that...)

Any great ideas? :)
 
ManTic said:
Hey :)

I'm rather new with PICs and C, and I just found out that the program I wrote for my PIC16F877 is about 10-12kb big (depending of the amount of writing I do to the LCD)... And the PIC can only hold 8kb

I am using SourceBoost's C++ compiler...

Some of my methods aren't that clever, because the compiler has some limitations (compared to some code i saw compiled with IAR's C compiler - sourceBoost couldn't compile that...)

Any great ideas? :)

You need to write your program more efficiently, probably your first task is to find out what's using the most memory. 10K of generated PIC code is a HUGE program!.

But any high level compiler is likely to generate much longer code than assembler, but even if you write in assembler you have the problems of page switching.
 
What are you trying to do?.... perhaps you can use a EEPROM with the message stored in there for the LCD so that the PIC doesn't have to carry it on its program.... I bet you anything that you have a lot of LCD messages taking up space. I am not sure what compiler is that one that you are using, but a LCDOUT routine in a lot of the compilers are very inefficient and generate a whole bunch of ASM code. Also make sure that the files you include with your program need all that they have inside.... there are sometimes declarations that really don't need to be there if you are not using them.

Good LUck

Ivancho
 
The easiest solution would be to buy a PIC with more Flash memory. That does sound like a lot of code though. Are you using floating point? - the libraries are HUGE. Also make sure you arn't using 16 or 32 bit variables except when absolutely nessesary (make everything an unsigned char when possible). They not only take more ram they also require more code space to implement.

Brent
 
"(make everything an unsigned char when possible)"...

The problem is that the compiler I use, can't compile unsigned chars...

Anyway.. I looked the code through, made som adjustments (Yes, there was a lot of LCD writing) and then i also found out that PIC16F877 can actually hold 14,3kb of programcode...

Thankx anyway guys...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top