|
|
View previous topic :: View next topic |
Author |
Message |
naveen13m
Joined: 01 Jun 2012 Posts: 4 Location: India
|
Memory allocation doubt |
Posted: Sat Jun 02, 2012 7:46 am |
|
|
I have a PIC16F882 microcontroller and it has a program memory of 3.5kb, 128 bytes of RAM. The file LCD.c is around 14kb and if my code is around 3kb then where will this lcd.c be stored in the microcontroller if i use lcd.c in my code ? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sat Jun 02, 2012 9:41 am |
|
|
The .c code is not stored in the PIC. The .c code feeds the compiler which generates a much smaller binary image. It is this binary image which is stored in the PIC. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
naveen13m
Joined: 01 Jun 2012 Posts: 4 Location: India
|
|
Posted: Sat Jun 02, 2012 1:11 pm |
|
|
If the programmable memory is only 3.5kb can i use both ADC and LCD at the same time i.e even after creating the image, will this be sufficient? |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Sat Jun 02, 2012 1:23 pm |
|
|
It all depends on how much of the code you use. CCS only creates code for parts that you use. The only real way to know is toss a program into the compiler, compile it, and see how much space it takes up. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Sat Jun 02, 2012 2:51 pm |
|
|
Yes.
It is important to understand, that you can write one line of code, that uses several KB of actual ROM, or hundreds of lines that use just a few bytes. A single FP maths function, combining perhaps log's and sin's, can use more memory than many small PIC's have in them, but lines like defines, use no actual storage at all, till they are used, and even then only a very few bytes.
Now, the 16F882, does not have 3.5kb of memory. First, 'b' means bits, not bytes, but also the memory here is in 14bit 'words', of which it has 2048. Now to give an idea of what that can hold, I have a program, which uses flex_lcd, handles an I2C master, three ADC channels, keyboard, and a small command parser, which uses just 1881 words. 8.4KB, + 5KB, + 29.4KB + 20.7KB of source code.
However (conversely), I have another project here, which is under 4KB of source, and occupies 91000 words in the final chip.
You should be able to write a program that drives the LCD, and reads the LCD, occupying only a few hundred bytes. However switch to using complex arithmetic, and trying to print the results, and expect to have no hope at all....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|