Jump to content
Sign in to follow this  
EngIP

Storing constants in flash?

Recommended Posts

Hi all,

 

I'm trying to make a LED matrix display characters - I've decided on a format using coordinates, and the coordinates for each character are stored in two separate arrays (one array is a vertical position, one the horizontal). E.g.

 

The letter T -

file.php?mode=view&id=303&sid=96a93978a149a0feed9442542cc11c63

 

Would have two arrays, namely

 

unsigned char THrz[12] = {12,5,4,3,2,1,3,3,3,3,3,3};
unsigned char TVert[12]= {12,1,1,1,1,1,2,3,4,5,6,7};

 

The first element of the array is the array length, used for ease of program control. This way I can cycle through the loop with the following code

 

for (x=THrz[0];x>0;x--){
//send coordinates of  LED to be lit to the bitbang function
bitbang(THrz[x],TVert[x]);
}

 

My problem is that I can't declare my character arrays, as there isn't enough room (compiler (CCS) gives a memory error). After a post from Zeke, I've realised that declaring variables the way I am isn't writing them to the appropriate section of memory, and I should probably be writing to Flash memory? I've had a look at some info and code from TI, but it seems quite a complex way of writing data to flash. Zeke tantalisingly mentioned there could be a simple way of writing it in C, and it would seem like something a compiler could do quite easily...

 

So, any help/clues? I've tried the documentation, but it's all a bit beyond me, and I'm sure I'm overlooking a very simple way of doing it.

post-2193-135135499642_thumb.jpg

Share this post


Link to post
Share on other sites

When I try to compile the following code, I get this:-

 

"../lnk_msp430f2012.cmd", line 56: error: run placement fails for object

".bss", size 0xa8 (page 0). Available ranges:

RAM size: 0x80 unused: 0x4e max hole: 0x4c

error: errors encountered during linking; "MSP-EXP430G2-Launchpad.out" not

built

 

error.

 

#include 

const unsigned char GV[80];

void main(void) {
WDTCTL = WDTPW + WDTHOLD;		// Hold the WDT (WatchDog Timer)
P1DIR = 0xFF; 					//Set Port 1 as outputs


	while(1){
		int x=100;
	} 
}

 

What is wrong? The error message suggests it's a RAM issue, and if I reduce the size of the array (to 60) it will compile.

Share this post


Link to post
Share on other sites
When I try to compile the following code, I get this:-

 

"../lnk_msp430f2012.cmd", line 56: error: run placement fails for object

".bss", size 0xa8 (page 0). Available ranges:

RAM size: 0x80 unused: 0x4e max hole: 0x4c

error: errors encountered during linking; "MSP-EXP430G2-Launchpad.out" not

built

 

error.

 

#include 

const unsigned char GV[80];

void main(void) {
WDTCTL = WDTPW + WDTHOLD;		// Hold the WDT (WatchDog Timer)
P1DIR = 0xFF; 					//Set Port 1 as outputs


	while(1){
		int x=100;
	} 
}

 

What is wrong? The error message suggests it's a RAM issue, and if I reduce the size of the array (to 60) it will compile.

 

Do it this way, because it is CONST you -must- initialize it with the known values because you cannot change it later.

 

#include 

const unsigned char GV[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void main(void) {
WDTCTL = WDTPW + WDTHOLD;		// Hold the WDT (WatchDog Timer)
P1DIR = 0xFF; 					//Set Port 1 as outputs


	while(1){
		_NOP();
	} 
}

 

That is 80 0's.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...