-3
\$\begingroup\$

i am programming pic microcontroller using mikro c , i want to store array of 8 bit samples generated from audacity (it's a software used to generate header file from audio file) , i got one header file and copied it to one new file and saved as "const sample[ ]={hex samples};" And saved it in main file i included this header file but I am facing error " there is not enough rom space" , please help me out guys,,,thanks

\$\endgroup\$
  • 1
    \$\begingroup\$ I guess probably because you are using free version of Mikro C which limits the size of the file (i.e. long time ago, it was 1 or 2Kbyte), therefore, you need to upgrade the version. \$\endgroup\$ – CroCo Oct 19 '16 at 11:33
  • 1
    \$\begingroup\$ Then you need to provide us with a minimal working example that regenerates the error so that we can see what's going on. \$\endgroup\$ – CroCo Oct 19 '16 at 11:35
  • 2
    \$\begingroup\$ How big is the header file (in bytes?) How big is the ROM in your PIC (in bytes?) Which is bigger? See any problem? \$\endgroup\$ – JRE Oct 19 '16 at 11:41
  • 1
    \$\begingroup\$ And how many bytes are you going to store in your array? Isn't it possible that there indeed is not enough memory? Check: How much ROM do you have, how much rom is needed for your entire code, when you keep that array empty? The rest is what's left for your array. \$\endgroup\$ – sweber Oct 19 '16 at 11:41
  • 1
    \$\begingroup\$ @user103110 Lower the sample rate or implement some sort of compression. Something like LZO might be sufficient. \$\endgroup\$ – Polynomial Oct 19 '16 at 13:41
3
\$\begingroup\$

Basically, you can't cram 20 pounds of data into a 10 pound memory.

Either try to store less data or get a bigger memory.

Also look carefully how exactly you are storing the data in the program memory of the PIC. You are thinking of this in terms of "files", which makes no sense. To use microcontrollers effectively, you have to actually understand what is going on at the low levels. Make sure these byte samples are really stored in successive bytes of program memory. Also make sure your compiler isn't imposing some arbitrary memory size restriction.

The easiest way to make sure the data is being stored effectively in program memory with the right format is to use assembly language for that one module. Note that on a PIC 18 (you didn't say which PIC, let alone what family), you need to put this data into a CODE_PACK section, not a normal CODE section.

\$\endgroup\$
2
\$\begingroup\$

You said that you declared the storage as:

const sample[ ]={hex samples};

I'm not sure about the mikro c compiler, but most c compilers will default to storing that as an array of 16-bit integers. Since you said that you have 8-bit samples you need to declare the storage as

const unsigned char sample [ ]={hex samples};

This should take up half of the memory space.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.