Jump to content

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): 



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

void delay(unsigned int number) {
	while(number--) {

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]);


#ifndef M_H_
#define M_H_

#include <stdint.h>

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

#endif /* M_H_ */


#include "m.h"

#pragma LOCATION(m1, 0x8000);
const uint8_t m1[128] = {

#pragma LOCATION(m2, 0x7F80);
const uint8_t m2[128] = {
Link to post
Share on other sites

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

Try this:

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

#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:

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
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 
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 
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.

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...