This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using flash memory in msp430f2259

Other Parts Discussed in Thread: MSP430F5529, MSP430F5659

Hello,

I have problems using the flash memory. The compiler aparently works, but when I execute the program it doesn't work in the board, it doesn't save the results of the operation in the variable.

Thanks.

#include <msp430.h>                
#include <stdio.h>

unsigned int i=2;
unsigned int j=2;


float retardos [2][4]={
        0, 0, 0, 0,
        0, 0, 0, 0 };
float coef [2][5]={
        0.028, 0.053, 0.071, 0.053, 0.0028,
        1, -2.026, 2.148, -1.159, 0.279};

float salida_b=0;

const unsigned int tamano = 512; //Tamaño del array

float datos [512] = {      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
    };

#pragma LOCATION( salida , 0x004444 );
float salida[512];

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;
    salida[0]=0;

    for (i=1; i<tamano; i++){

        salida_b = coef[0][0]*datos[i-1]+coef[0][1]*retardos[0][0]+coef[0][2]*retardos[0][1]+coef[0][3]*retardos[0][2]+coef[0][4]*retardos[0][3];
        salida[i] = salida_b-(coef[1][1]*retardos[1][0]+coef[1][2]*retardos[1][1]+coef[1][3]*retardos[1][2]+coef[1][4]*retardos[1][3]);


        for (j=1; j<4 ; j++) {
            retardos[0][j]=retardos[0][j-1];
            retardos[1][j]=retardos[1][j-1];
        };

        retardos[0][0]=datos[i];
        retardos[1][0]=salida[i];

    };

    while(1);
}

  • Check first if this is the right MCU: MSP430F2259?

    Then check if it has RAM starting at location: 0x04444?

  • Yes, the reference is MSP430F5529.

    I think I'm doing properly, but I'm not sure.

    This is the memory map:

  • Then you have 4 RAM sectors (+USB RAM), starting at 2400h and ending at 43FFh. 4444h is outside of RAM.

    But why you want to use the pragma to locate the memory space, you can overlap your other RAM (variables and stack) on this way.

  • Memory RAM is not enogh, because I want to locate more than 512 float number, 512 is for a test. This is why I want to use the Flash memory.

  • First you have to create Flash space for your data in the Linker Command File, see ‘MSP430 Optimizing C/C++ Compiler’.

    Writing to Flash needs a special process, see ‘Flash Memory Controller’ in the Users Guide.

  • Jose,

    Jose Balsa Gonzalez said:

    Memory RAM is not enogh, because I want to locate more than 512 float number, 512 is for a test. This is why I want to use the Flash memory.

    You can't use Flash as your data memory. You need to use SRAM for this. You can use it to store constants suce as the variable "datos" in your code above, but not for storing data such as "salida" or "retardos". If the memory doesn't fit, you might want to consider bigger device such as MSP430F5659. 

**Attention** This is a public forum