View previous topic :: View next topic |
Author |
Message |
water_river
Joined: 17 Feb 2004 Posts: 16
|
16F877-Not Enough RAM for variables?? |
Posted: Fri Feb 27, 2004 7:51 am |
|
|
hi,all
I wrote a program to interface a keyboard and LCD. I created an array of charactes whose length is 128. After clicking "build all", it said that there is not enough RAM for variables. Did anyone meet this problem before?? Could you please give some thoughts?? thanks in advance.
I am using MPLAB6.40 and PCM to program PIC16F877 |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Fri Feb 27, 2004 8:41 am |
|
|
If you can post your code, that would help. Also, what version of the CCS compiler are you using? You gave the MPLAB version but if you are writing your code in C and compliling with CCS then we need to know that one too... _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
Re: 16F877-Not Enough RAM for variables?? |
Posted: Fri Feb 27, 2004 8:49 am |
|
|
water_river wrote: | hi,all
I wrote a program to interface a keyboard and LCD. I created an array of charactes whose length is 128. |
On the PIC16 series, an array cannot be larger than the largest bank size. On most PICs that is 80bytes, some PICs have a 96byte bank. |
|
|
Guest
|
|
Posted: Fri Feb 27, 2004 11:12 am |
|
|
You can do array of 256 bytes max.
By default, the CCS will use an 8 bits pointer to access ram, so if you have more than 256 bytes of variables it will say that ram is full.
To be able to access full ram you need to add the instruction
#device *=16
in the header file. |
|
|
Guest
|
|
Posted: Fri Feb 27, 2004 11:15 am |
|
|
I made an error on the previous answer.
Array can be 256 bytes max when they're constant. ( in rom)
On ram they cant be bigger than a the available space in a bank like Darren Rook said. |
|
|
CT Guest
|
Re: 16F877-Not Enough RAM for variables?? |
Posted: Fri Feb 27, 2004 7:13 pm |
|
|
It may be an obvious solution, but if you really need an array that size, a simple memory manager could be written for reading/writing the arrays.
For example, define two 64-byte arrays and have a function that, when handed the address, simply writes/returns the data.
The function would then, say, use the first array for 0-63 and the second for 64-127. |
|
|
water_river
Joined: 17 Feb 2004 Posts: 16
|
|
Posted: Sat Feb 28, 2004 1:04 am |
|
|
Thank you very much for the solutions.
BTW, the PCM compiler I used is quite old. Right now I am not able to check out its version. |
|
|
|