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

*** Error 71 "alarm2.c" Line 545(1,2): Out of ROM,

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
qwwe



Joined: 17 Sep 2017
Posts: 59

View user's profile Send private message

*** Error 71 "alarm2.c" Line 545(1,2): Out of ROM,
PostPosted: Thu Nov 23, 2017 2:17 pm     Reply with quote

Hi, I want to save a sound that I've converted to Hex code into ROM memory Microcontroller and then play it through the Changing the PWM duty cycle.
But when compiling, it gives the following error:

Code:

*** Error 71 "alarm2.c" Line 545(1,2): Out of ROM, A segment or the program is too large    @const688
  Seg 00003-007FF, 07FD left, need 01FC9
  Seg 00000-00002, 0000 left, need 01FC9 Reserved

      1 Errors,  0 Warnings.
Build Failed.


Code:

#include <16f1823.h>
#device *=16
#fuses NOWDT            //NO Watch Dog Timer
#fuses PUT            //Power Up Timer
#fuses NOLVP          //No low voltage programing
#fuses NOCPD          //No EE protection
#fuses NOPROTECT      //Code not protected from reading
#fuses NOWRT          //Program memory not write protected
#fuses NODEBUG        //No Debug mode for ICD
#fuses NOBROWNOUT     //No brownout reset
#USE DELAY (internal=1000000)
#include <stdio.h>
#include <string.h>

int32 i;
const char hoshdar[8128] = {0x52, 0x49, 0x46, 0x46, 0xB8, 0x1F, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20,.............
.............
.............
};
void main()
{
set_tris_c(0b11101111);
output_low(PIN_C5);
setup_timer_2(T2_DIV_BY_1,20,1);

setup_ccp1(ccp_pwm);


while(TRUE)
{
 
for(i=0;i<8128;i++)
{

set_pwm1_duty(hoshdar[i]);
}
}
}



Thanks for the advice
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Nov 23, 2017 2:44 pm     Reply with quote

You really,really need to read the datasheet ! I know, 400 pages of dull, boring information, but a lot of it is very,very important. I downloaded the DS and saw that in the 'family types' chart on page 4 it says that PIC has 2K words of program storage.
so....
do you think you can store 8,000 bytes of data AND your program into 2K words ??

THIS is why it is CRITICAL to read any PICs datasheet. Even after 20 years of 'playing with PICs' I scan all the pages, read entire chapters 2-3 times when I'm using a new peripheral . It's 'little' details like VDD vs speed charts, odd register definitions, clock configurations...that you need to understand. Those are just some of the reasons I've standardized all my products on the PIC18F46K22. I've yet to run out of pins,peripherals or memory...

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Nov 23, 2017 3:09 pm     Reply with quote

Particularly on a PIC16, where each ROM location only holds 14bits, so a whole ROM word has to be used for every byte.
qwwe



Joined: 17 Sep 2017
Posts: 59

View user's profile Send private message

PostPosted: Thu Nov 23, 2017 11:26 pm     Reply with quote

Now, what should I do to solve the problem?
I did not get it right.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 12:06 am     Reply with quote

Attach something like an external EEPROM, and store your data in this.

A little 24128. will give you 16K bytes of storage.

Only two wires needed (preferably the hardware MSSP lines), drivers in the standard library.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 5:44 pm     Reply with quote

The other option is to select a PIC with a LOT more 'program memory'. PICs are really , really inexpensive today.
If this is a hobby, consider a 40 pin device with TWO hardware UARTs and 32 or 64KW of memory.
I've been using the PIC18F46K22 as my 'goto' PIC for years now and have yet to run out of memory or peripherals.It's also good for either 3V or 5 V operation at 64MHz !
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 7:14 pm     Reply with quote

temtronic wrote:
PICs are really , really inexpensive today.
If this is a hobby, consider a 40 pin device with TWO hardware UARTs and 32 or 64KW of memory.


I don't like the 64kW models. The heat sinks are too unwieldy.

Laughing

[I'm teasing]
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 8:55 pm     Reply with quote

Reminds me of how we checked for a bad RAM chips in the 70s..
test each chip by touching with a finger, the one that burnt you was the bad one ! Easy to replace as everything was in sockets back then ! Good old days... Smile
qwwe



Joined: 17 Sep 2017
Posts: 59

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 11:19 pm     Reply with quote

I used the 16f1829 IC, but it still has the same problem
This IC has 8 KB of memory.
And I also reduced the size of the array.Because I used the Midi format this time to reduce the volume of the song
Code:

#include <16f1829.h>
#device *=16
//#fuses HS             //High speed Osc (> 4mhz for PCM/PCH)
#fuses NOWDT            //NO Watch Dog Timer
#fuses PUT            //Power Up Timer
#fuses NOLVP          //No low voltage programing
#fuses NOCPD          //No EE protection
#fuses NOPROTECT      //Code not protected from reading
#fuses NOWRT          //Program memory not write protected
#fuses NODEBUG        //No Debug mode for ICD
#fuses NOBROWNOUT     //No brownout reset
#USE DELAY (internal=1000000)
#include <stdio.h>
#include <string.h>

int16 i;
const unsigned Char data[2088] = {
0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x02,
.........
.......
};
void main()
{
set_tris_c(0b11101111);
output_low(PIN_C5);
setup_timer_2(T2_DIV_BY_1,30,1);

setup_ccp1(ccp_pwm);


while(TRUE)
{

for(i=0;i<2088;i++)
{

set_pwm1_duty(data[i]);
}
}
}



This time, this error

Code:

*** Error 71 "alarm2.c" Line 168(1,2): Out of ROM, A segment or the program is too large    @const760
  Seg 00003-007FF, 07FD left, need 00831
  Seg 00800-00FFF, 0800 left, need 00831
  Seg 01000-017FF, 0800 left, need 00831
  Seg 01800-01FFF, 0800 left, need 00831
  Seg 00000-00002, 0000 left, need 00831 Reserved

      1 Errors,  0 Warnings.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Nov 25, 2017 6:31 pm     Reply with quote

hmm you need to post your compiler version !! Critical

While the #device =16 should have allowed the memory to appear contiguous, perhaps it's a compiler bug.

Curiously it needs 0x831 which is 2097 decimal and your array is 2088. Maybe the 10 extra bytes are 'overhead' but it is a 'red flag' to me.

Makes me wonder if you're trying to use a 'student' version of the compiler where it's 'range' is limited ??


Again, please post compiler version.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 25, 2017 10:28 pm     Reply with quote

The compiler is not allowing a 'const' array to be larger than a Flash
memory page. I can't find this documented anywhere, so far.
They do document that a function can't exceed a 'segment' (Flash memory
page size): https://www.ccsinfo.com/faq.php?page=out_of_rom

The page size for the 16F1829 is 2K. So that's why you're getting the
error. Your array exceeds 2K. Also, a few more ROM words are added
by the compiler to allow accessing the array data.

One simple solution is to break up the array into two or more smaller
arrays. Then add code to access the correct array based on the index
value. Look at the CCS driver file, Graphics.c. (This is in the \Drivers
folder in the CCS installation folder on your PC). It has two font arrays,
named FONT and FONT2. Each one contains part of the font data.
Look at the glcd_text57() function. It has the following code which
selects the correct array to use, depending on the index value:
Code:
if(*textptr < 'S') // Checks if the letter is in the first font array
         memcpy(pixelData, FONT[*textptr - ' '], 5);
      else if(*textptr <= '~') // Check if the letter is in the second font array
         memcpy(pixelData, FONT2[*textptr - 'S'], 5);
      else
         memcpy(pixelData, FONT[0], 5);   // Default to space
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Nov 26, 2017 6:57 am     Reply with quote

Interesting what PCM P says.....makes 100% sense. Also 'interesting' that the CCS code gets around the 'bug'. Makes me thik they knew about it back then and have never addressed the issue, maybe since no ones reported it ??
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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