PIC variable memory

Thread Starter

powzoom

Joined Jan 18, 2009
41
I'm using a pic16F688 and it has 7k of program memory. When I try to create an array of structs, hi-tech C lite in Mplab tells me that there is not enough space to allocate.

struct s_RhythmPattern
{
unsigned char Meter; // how many beats in measure. 2/3/4/5/6...
char Name[8]; // the name of the rhthym
unsigned char Measures; // how many measures in the pattern
unsigned int Rhythm; // The rythm pattern, 1 is beat, 0 is no beat
} ;


struct s_RhythmPattern Rhythms[7];
//struct s_RhythmPattern Rhythms2[6];

The struct should have 96 bytes of data
When I declare an array of size 7, (672bytes) it gives an error saying not enough memory.
But I can create 2 or even 3 arrays of size 6 without any error as long as its lower than 7. Does it try to allocate a continuous block of memory? How can I get by this?
 

AlexR

Joined Jan 16, 2008
732
Your array is a variable and as such is stored in RAM, not program memory.
The PIC16F688 has 4K words of program memory and only 256 bytes of RAM.
 

Thread Starter

powzoom

Joined Jan 18, 2009
41
That make a little more sense but it still doesn't explain why I can have 2 size 6 arrays but not a single size 7. I guess I need a better pic with more ram.
 
Top