Jump to content
43oh

Program data at a fixed location


Recommended Posts

Hey guys, I have a 2 keyboard matrix that I would like the user to be able to customize via a PC program through BSL maybe, without giving them my source code. Each matrix consumes a block of 128 8-bits numbers. Is there a way I can make sure the blocks of data stays exactly at a location in the program memory every time the firmware is flashed onto the MSP430F5502 (or MSP430F55xx)?

Link to post
Share on other sites

Yes, you can direct your compiler to place data at exact location and your output file has information about location and size of your code/data.

If you don't want to load just data (128 bytes) and not the code, you can do that too.

Link to post
Share on other sites

I'm quite new to flash and memory management in general, so please bear with me.

 

Firstly, I'm using TI compiler, where can I find this option? Secondly, in TI MSP430 Training ROM, it says:

const: used to declare a constant, [...] It is stored in data memory, not in program memory. 

Is data memory flash or RAM? I declared my matrix using const. Thirdly, I'm only seen BSL being used for flashing a complete TI-TXT onto the uC. Would it be possible to use BSL to flash only that 256 bytes of memory?

Link to post
Share on other sites

Referring to http://processors.wiki.ti.com/index.php/Placing_Variables_in_Specific_Memory_Location_-_MSP430 and MSP430F5502 and MSP430F5510's LNK files, I made 2 matrix at locations 0x8000 and 0x7F80, so it may work on both chips. However, during compilation, there's this warning: 

#10325-D creating memory range $BOUND$0x7f80 to accommodate BOUND section ".TI.bound:m2"

This prevents flashing the device and gave this error:

MSP430: Trouble Writing Memory Block at 0x7f80 on Page 0 of Length 0x80: Could not write device memory
MSP430: GEL: File: D:\MSP430_workspace\FixedPointFlash\Debug\FixedPointFlash.out: Load failed.

Can I get some help with this?

 

CODE (I wrote the code so that it has similar structure to my main project): 

 

main.c

#include <msp430.h> 
#include "m.h"

void delay(unsigned int number) {
	while(number--) {
		__delay_cycles(1000);
	}
}

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	
    PJOUT = 0;
    PJDIR |= BIT2;
    
    int i;
    
    while(1) {
    	//flash LED
    	PJOUT ^= BIT2;
    	for(i = 0; i < 127; i++) delay(m1[i]+m2[i]);
    }
}

m.h

#ifndef M_H_
#define M_H_

#include <stdint.h>

extern const uint8_t m1[128];
extern const uint8_t m2[128];

#endif /* M_H_ */

m.c

#include "m.h"

#pragma LOCATION(m1, 0x8000);
const uint8_t m1[128] = {
		0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
		26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
		49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,
		72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,
		95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,
		114,115,116,117,118,119,120,121,122,123,124,125,126,127
};

#pragma LOCATION(m2, 0x7F80);
const uint8_t m2[128] = {
		128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,
		146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,
		164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,
		182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,
		200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,
		218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,
		236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255};
Link to post
Share on other sites

That's because F5510's memory starts at 0x8000 and F5502's at 0xA000

Try this:

//F5510
#pragma LOCATION(m1, 0x8000);
#pragma LOCATION(m2, 0x8080);

//F5502
#pragma LOCATION(m1, 0xA000);
#pragma LOCATION(m2, 0xA080);

If you want something universal for all F550x chips, you can use 0xF000. Your out file will then look similar to this:

@8000
2A 14 3F 40 00 00 3F 90 01 00 23 28 3F 40 00 00 
3F 90 01 00 1E 28 3A 40 00 00 3A 80 00 00 3A 50  
...
...
F8 23 10 01 32 D0 10 00 FD 3F 1C 43 10 01 03 43
FF 3F
@f000
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
...
...
E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF 
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF 
@ffd2
D4 80 D4 80 D4 80 D4 80 D4 80 D4 80 D4 80 D4 80 
D4 80 D4 80 D4 80 D4 80 D4 80 D4 80 D4 80 D4 80 
D4 80 D4 80 D4 80 D4 80 D4 80 D4 80 A4 80 
q
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.

×
×
  • Create New...