CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RAM/ROM problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Fri Sep 30, 2005 12:46 am     Reply with quote

PCM programmer wrote:
Quote:
I do use one array and want it to be 128 bytes but I can only make it 80 bytes big.

You can't make an array larger than the PIC's largest RAM bank size
with CCS. Also, for PICs that have "common RAM" (accessible with
any bank setting), the compiler likes to reserve that area for its own use.
So for the 16F877A, the largest possible array size is 96 bytes.


I didn't know, I thought the max was 128 bytes. Thanks!

PCM programmer wrote:
If you have a lot of other variables, you may not have enough RAM left to make a 96 byte array. The array must be contained within one bank. It cannot span two or more banks.


If I use that array I use 96 bytes. I have another 4 bytes and 3 bits as global variables. In my code I use at most another 23 bytes. So At most I use 123 bytes and 3 bits. This is less than the RAM available (as far as I know...) The LST file says the same. So why does my code still gives an out of RAM error, even when I am sure, I use less then the available RAM?

Also, if I use 81 bytes for the array, the compiler gives an out of ROM error, while with 80 bytes it runs normally. Can someone explain me this?

Humberto wrote:
mmmh... your problem is not visible for us if you only post the header.

I understand but I cannot post the whole code and expect anybody to solve it.

Humberto wrote:
Anyway, the CCS Compiler version you are using was released in 2001 and almost all early 3.0xx versions were very unstable.
Most of us had been used those versions just to test and smell whats new, but the real projects had being done with the old battle horse V2.748.

I'll try to get an update to an 3.2xx version or the 2.748 version. Thanks for the information!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 30, 2005 1:15 am     Reply with quote

Read my post in the following thread which explains how to use
the #locate directive to (possibly) fix your problem.
http://www.ccsinfo.com/forum/viewtopic.php?t=20605
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Fri Sep 30, 2005 2:36 am     Reply with quote

PCM programmer wrote:
Read my post in the following thread which explains how to use
the #locate directive to (possibly) fix your problem.
http://www.ccsinfo.com/forum/viewtopic.php?t=20605


This did solve my RAM problem!!! Very much thanks!

I tried the same with my ROM problem and the #ORG directive but that didn't solve it. Is there also a similar solution for my ROM problem. I do like to use more than 25% of my ROM Wink
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

RAM problem solved, ROM problem still exists
PostPosted: Mon Oct 03, 2005 1:59 am     Reply with quote

I got a new compiler version (v3.235) and now I can leave the #LOCATE directive out. As it seems the compler handled the RAM wrong. But the ROM problem still exists...

I could off course switch to a chip with more capacity, but I would like to use the current 16F877a.

Does anybody have any idea to solve my ROM problem?
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Thu Oct 06, 2005 2:37 am     Reply with quote

I still don't know what to do. If I compile my whole code I use 62% of my ROM. But it will only run for a small part and then restart the PIC. Sometimes it doesn't even run at all. (that depends on what functions I leave out of the program)

If I leave parts out so the code gets below 25% it will run smooth. But I can use the bootloader and get to 32% of code usage and it still runs.

So it seems I have to use the #ORG directive to allocate all my functions. But I do not like to do that.

Does anyone have an suggestion of how to solve the problem?

Any help is appreciated
akira
Guest







PostPosted: Mon Oct 10, 2005 7:17 pm     Reply with quote

i have same problem
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 10, 2005 9:20 pm     Reply with quote

Quote:
it will only run for a small part and then restart the PIC

Here are some tips:

Don't do anything weird.

1. Don't make large functions. Break them up into smaller ones.
2. Don't use "goto".
3. Don't use #asm code.
4. Don't use malloc.
5. Don't use #separate.
6. Don't use #org.
7. Don't use the Watchdog timer.
8. Don't use any special CCS function such as "goto_address()".
9. Don't try to exit from interrupt routines prematurely by
putting in some weird code.
10. Don't accidently write past the end of an array.
11. Don't try to use nested interrupts. i.e., Don't enable global
interrupts while still inside an interrupt routine.
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Oct 11, 2005 12:36 am     Reply with quote

@PCM programmer: Thanks for your tips, here are my reaction to them:
PCM programmer wrote:
1. Don't make large functions. Break them up into smaller ones.
I'm splitting p as much as possible, but if I insert a lot of small functions I still get the same problem.

PCM programmer wrote:
2. Don't use "goto".
3. Don't use #asm code.
4. Don't use malloc.
5. Don't use #separate.
6. Don't use #org.
7. Don't use the Watchdog timer.
8. Don't use any special CCS function such as "goto_address()".
9. Don't try to exit from interrupt routines prematurely by putting in some weird code.
10. Don't accidently write past the end of an array.
I don't.

PCM programmer wrote:
11. Don't try to use nested interrupts. i.e., Don't enable global interrupts while still inside an interrupt routine.
I only use 1 interrupt.

@Akira: which hardware/programmer do you use? I more and more get the feeling that it is a hardware problem.
I use the ClearView Mathias from TechTools
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 11, 2005 7:28 pm     Reply with quote

Quote:
I more and more get the feeling that it is a hardware problem.

It has been noted many times on here that the 16F877 "A" seems
flakier than the 16F877. Do you have 0.1 uF capacitors between
each Vdd pin and GND ? (and placed very close to the pins).

One test would be to replace the "A" chip with a "non A" chip.
See if it gets better.


Quote:
I use the ClearView Mathias from TechTools

Have you actually ever run this program on a PIC chip, or has
all your development and testing been entirely on the ICE ?
If so, maybe you've got ICE problems. I would test it on
a real PIC.
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Wed Oct 12, 2005 12:58 am     Reply with quote

PCM programmer wrote:
It has been noted many times on here that the 16F877 "A" seems flakier than the 16F877. Do you have 0.1 uF capacitors between each Vdd pin and GND? (and placed very close to the pins).
They are in place.

PCM programmer wrote:
One test would be to replace the "A" chip with a "non A" chip. See if it gets better.
I'll do that asap!


PCM programmer wrote:
Quote:
I use the ClearView Mathias from TechTools
Have you actually ever run this program on a PIC chip, or has all your development and testing been entirely on the ICE? If so, maybe you've got ICE problems. I would test it on a real PIC.
I am waiting for a new hardware revision (coming end of this week) And then can switch to another programmer (ICD) to try and solve the problem. And if that doesn't work I'll program right on the PIC.
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Wed Oct 12, 2005 1:13 am     Reply with quote

PCM programmer wrote:
One test would be to replace the "A" chip with a "non A" chip. See if it gets better.
No change, still it doesn't work...
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Wed Oct 12, 2005 6:43 am     Reply with quote

Quote:
PCM programmer wrote:
Have you actually ever run this program on a PIC chip, or has all your development and testing been entirely on the ICE? If so, maybe you've got ICE problems. I would test it on a real PIC.
I am waiting for a new hardware revision (coming end of this week) And then can switch to another programmer (ICD) to try and solve the problem. And if that doesn't work I'll program right on the PIC.
It works!
Programming with a ICD-U solved all my problems. I got an unfinished prototype and if I compile all my code into it, it runs as it should do!

Many thanks!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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