View previous topic :: View next topic |
Author |
Message |
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
arrays - no memory space |
Posted: Thu Jan 20, 2005 9:49 am |
|
|
I am using PIC16F877A, compiler version 3.190.
I have got quite few arrays in my program, and that causes not enough memory space in RAM.
When I use #locate, the program counter becomes noughty and does not follow the program addresses sequence, and the code does not work then.
It seems like if I use const arrays instead, I can't use pointers
So, my code then doesn't work.
What is the solution for that?
Thank you _________________ Alex |
|
|
Ttelmah Guest
|
Re: arrays - no memory space |
Posted: Thu Jan 20, 2005 11:45 am |
|
|
alexz wrote: | I am using PIC16F877A, compiler version 3.190.
I have got quite few arrays in my program, and that causes not enough memory space in RAM.
When I use #locate, the program counter becomes noughty and does not follow the program addresses sequence, and the code does not work then.
It seems like if I use const arrays instead, I can't use pointers
So, my code then doesn't work.
What is the solution for that?
Thank you |
A chip with more space, or use smaller arrays...
You have to be aware, that if you use #locate, you must understand the limitations (some areas are shared between banks, the compiler needs RAM for it's variables, putting things that are commonly accessed in high banks will result in an increase in bank switching code etc..). Obviously if these do not need to be variables, then use #const. No, you cannot have pointers to constant arrays (this is in the manual).
Best Wishes |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Thu Jan 20, 2005 12:26 pm |
|
|
You can use the #ROM directive to put stuff in program ROM, and as a bonus when you do that the data is a 14 bit word. I've found there's a limit to how much data the compiler lets you store that way, though. If you need more, you can make an addition to your program's HEX file before burning the program in--tedious to do, but works OK.
But if it's RAM you need, pure and simple, then you need a bigger processor, or an off-board RAM. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: arrays - no memory space |
Posted: Thu Jan 20, 2005 1:04 pm |
|
|
alexz wrote: | I am using PIC16F877A, compiler version 3.190.
I have got quite few arrays in my program, and that causes not enough memory space in RAM.
When I use #locate, the program counter becomes noughty and does not follow the program addresses sequence, and the code does not work then.
It seems like if I use const arrays instead, I can't use pointers
So, my code then doesn't work.
What is the solution for that?
Thank you |
Don't use pointers. You can always copy the data to a RAM arrray and then use a pointer to it. |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
FRAM |
Posted: Thu Jan 20, 2005 3:22 pm |
|
|
If your board isn't finished you could add an fram.
It is nearly and fast as ram.
I2C,.. so its easy to hook up.
drivers are writen for it.
I use the ramtron fm24c04 FRAM. |
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
|
Posted: Fri Jan 21, 2005 3:14 am |
|
|
Thank you guys _________________ Alex |
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
Re: FRAM |
Posted: Fri Jan 21, 2005 3:14 am |
|
|
treitmey wrote: | If your board isn't finished you could add an fram.
It is nearly and fast as ram.
I2C,.. so its easy to hook up.
drivers are writen for it.
I use the ramtron fm24c04 FRAM. |
what is FRAM? _________________ Alex |
|
|
Kieran
Joined: 28 Nov 2003 Posts: 39 Location: Essex UK
|
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
Re: What is FRAM |
Posted: Fri Jan 21, 2005 4:31 am |
|
|
Thanks, I just think that to use an additional external component is not such a good solution.
I am developing a USB device using PIC16F877A and USBN9603 USB controller of National.
I am thinking of changing all that to one of the new PIC18 series with USB controller on chip and also bigger memory, for example PIC18F4550.
But then I will obvously have to change all my code, written up to now, and probably write the new code using the PIC18 compiler won't I?
And that really slows down my desicion.
What do you think guys? _________________ Alex |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Fri Jan 21, 2005 8:48 am |
|
|
Go for it. Yes, you'll spend some time porting to the 18-family, but all the code you've written is still valid.
Plus, buying the PCH compiler will allow you to target a lot of new chips.
I learned a long time ago that if I try to scrimp and save on tools, that I'll just end up paying for it later (either for the tool I should have bought in the first place, or in time lost). Spending a little money on a great development tool (PCH) is money well spent, in my opinion. |
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
|
Posted: Fri Jan 21, 2005 8:51 am |
|
|
newguy wrote: | Go for it. Yes, you'll spend some time porting to the 18-family, but all the code you've written is still valid.
Plus, buying the PCH compiler will allow you to target a lot of new chips.
I learned a long time ago that if I try to scrimp and save on tools, that I'll just end up paying for it later (either for the tool I should have bought in the first place, or in time lost). Spending a little money on a great development tool (PCH) is money well spent, in my opinion. |
What is PCH ?
Will I be able to write in CCS and not in C18? _________________ Alex |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Fri Jan 21, 2005 9:03 am |
|
|
Whoops. I'm confused.
I thought that you were using the CCS compiler to write your application. There are 3 different versions of the CCS compiler: one for the 12-series (PCB), one for the 16-series (PCM), and another for the 18-series (PCH).
Since you mentioned that you were writing code for a 16F-something PIC, I assumed that you owned the CCS PCM compiler. If this was true, then all you'd need to do in order to upgrade to the 18-series PICs would be to buy CCS's PCH upgrade.
Sorry. Porting code written for another compiler will be a little painful, but I still think that CCS is a great product. |
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
|
Posted: Fri Jan 21, 2005 9:08 am |
|
|
newguy wrote: | Whoops. I'm confused.
I thought that you were using the CCS compiler to write your application. There are 3 different versions of the CCS compiler: one for the 12-series (PCB), one for the 16-series (PCM), and another for the 18-series (PCH).
Since you mentioned that you were writing code for a 16F-something PIC, I assumed that you owned the CCS PCM compiler. If this was true, then all you'd need to do in order to upgrade to the 18-series PICs would be to buy CCS's PCH upgrade.
Sorry. Porting code written for another compiler will be a little painful, but I still think that CCS is a great product. |
Thank you, that opened my eyes now.
Yes, I am using the PCM now.
So, is there much difference between the PCH and PCM? _________________ Alex |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Fri Jan 21, 2005 9:15 am |
|
|
The only difference is that the PCH compiler allows you to target the 18-series PICs. Everything else is identical. I think that CCS charges $75 for the upgrade. It is WELL worth it. Plus, you get 30 days of free upgrades with the purchase. These upgrades are for all of their compilers (PCB, PCM, and PCH). So for $75, you gain the ability to write code for the 18 family, and you get your present compiler (PCM) upgraded to the latest version.
I know that I'll get jumped on for that, so I'll just save everyone the opportunity: I know that the latest version can be buggy. You can also download the "last known good" version with your 30 day download rights. |
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
|
Posted: Fri Jan 21, 2005 9:25 am |
|
|
Another question:
What is preferable PCH or C18?
And what are advantages and disadvantages? _________________ Alex |
|
|
|