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.

CCS/MSP430FR6820: Using information memory for functions/arrays

Part Number: MSP430FR6820
Other Parts Discussed in Thread: MSP430FR6822,

Tool/software: Code Composer Studio

Hello,

we need to get more free program memory in our project. Unfortunately we
cannot use a processor with bigger memory. Do you have any easy tips how
to increase available memory for a program?

One of our ideas is to move some functions to infoA/B/C/D segments. I
tried it - I found a function smaller than the info block. I wrote:
#pragma CODE_SECTION(myFunction, ".infoD")
void myFunction(void)
{.....

I also changed in cmd file this line (only this line): 
infoD (NOLOAD) : {} > INFOD

to this:
 .infoD : {} > INFOD 

I can build the program without any errors/warnings. When I run my program I can see in the memory browser that the function was written into the infoD block. However when the program is reaching the function, the MCU is getting frozen. Do you know how to make it working? Second option is to use information blocks to hold constants but I would need to unite all information block to one because I need to save an constant array containing 256 16bit values. But I do not know how to use the information memory like a one block. Do you know how to do it?
Thank you in advance.
  • Hi 

    1. We have the pin to pin device MSP430FR6822 which memory is double than FR6820. They have same package and pin defines.

    2. For the code hung up at function define in informemory, could  you make very simple demo to reproduce the issue to us?

       Have you enable the MPU or IPE function?

    3. To define a 256 words or 512 bytes, due to the information just have 512 bytes memory, You can just try to define it as below 

              *(unsigned char *) address = 0;  

       You can access all information memory by change the value of the address to save your 512 bytes data.

    Best regareds

    Gary

  • Hi, thank you for your reply.

    1. It is not so easy to exchange the processor not due to technical issues but due to company internal processes, suppliers etc.. however we are going to try it.

    2. Here is a very simple example of (not working) function in the info memory part:

    #include <msp430.h>
    #include <stdio.h>
    
    #pragma CODE_SECTION(myFunction, ".infoD")
    void myFunction(void) {
        printf("calling function\n");
    }
    /**
     * main.c
     */
    int main(void)
    {
    	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    	myFunction();
    	return 0;
    }

    3. to be honest I do not know how your example could help us or how to use it. If we used your example we even would have to copy the data in a loop to the info memory but we still would need a memory place for source data. I tried also this:

    #pragma LOCATION(aTable,0x1800)
    static const unsigned short aTable[256] = {1,2,3..}

    but it not buildable, it says "#10324-D BOUND section ".TI.bound:aTable" spans the boundary of an existing memory range INFOD" it means that my variable is bigger than INFOD part.

    Add question : Is it possible to decrease the size of used memory in debug mode ? If we compile it in release mode the code is about 2k smaller. The reason is clear but I am asking whether there is possible to decrease some buffers in settings etc. to have smaller code but slower debugging or something like that.

  • You probably need to explicitly make infoD (really all of the info segments) "X"-ecutable. See "Build Options->CCS General->MPU".

    If you haven't tried the optimizer, you really should -- even relatively low optimizations can reduce code size substantially. See "Build Options->CCS Build->MSP430 Compiler->Optimization".

  • Hi 

    You can disable the MPU and write your code like this

    #include <msp430.h>
    
    #pragma LOCATION(myFunction,0x1800)
    void myFunction(void) {
        P1OUT^=BIT0;
    }
    /**
     * main.c
     */
    void main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer
        P1DIR|=BIT0;
        PM5CTL0 &= ~LOCKLPM5;
        while(1)
        {
            myFunction();
            __delay_cycles(50000);
        }
    }
    

  • Thank you both,

    but neither of your advice works (I do not know whether I have to set the MPU in code or it could be done in project settings.. but it is now not important) Let's focus how to write an constant array into the information memory. I suppose it is simpler and the main reason is that I could utilize all the memory because I do not have any functions which have exactly 128B but I have an array which have exactly 512B.

  • Hi 

    Due to the array's name will cost some memory. I think you can't define an array with 512B size in a 512B memory. In my eyes, the only way you can use the 512B memory as 512B size is the #3 that I have mentioned before. Because it don't need a array's name, you just need to define a variable to trace the pointer's value.

    Best regards

    Gary

  • Hi Gary,

    thank you. I think I understund what you mean. You mean to read the memory I need to define a pointer like: 

    unsigned char *myConstantArray = (unsigned char*) 0x1800;
    // then I can access any value in the information memory like:
    unsigned char temp = myConstantArray[300];

    Is it correct?

    But the problem is that I do not know how to simply write constants to the information memory without using too much code. Because a solution like:

    unsigned char tempArray[] = {0, 1, 2, ...};
    unsigned short i;
    
    for(i = 0; i < 512; i++) {
        myConstantArray[i] = tempArray[i];
    }

    is useless because it would consume a lot of memory.

    Do you please know a solution?

    EDIT: maybe I did not highlited that I would like to use the information memory to save a constant table values which I know before compilation. I need only to simply write these values during "flashing" a firmware into an MCU. In runtime I need only to read the values I do not need to rewrite the values. (a CRC acceleration table will be saved into the information memory)

  • Team,

    can you help to respond us here?

    Thank you.

  • If you want to store data (512B) into Information memory:

    1) Declare as:

    #pragma DATA_SECTION(myConstantArray,".infoD")
    const unsigned myConstantArray[256] = {0, 1, 2, };

    2) Change the linker .cmd file (lnk_msp430fr6820.cmd) to combine all four information segments into one:

    [line 60 or so:]

    /*
    INFOA : origin = 0x1980, length = 0x0080
    INFOB : origin = 0x1900, length = 0x0080
    INFOC : origin = 0x1880, length = 0x0080
    INFOD : origin = 0x1800, length = 0x0080
    */
    INFOD : origin = 0x1800, length = 0x0200

    [line 186 or so:]

    /*
    .infoA (NOLOAD) : {} > INFOA
    .infoB (NOLOAD) : {} > INFOB
    .infoC (NOLOAD) : {} > INFOC
    */
    .infoD : {} > INFOD

**Attention** This is a public forum