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.

Optimize memory in CC2541

Other Parts Discussed in Thread: CC2541

I see the map file of my project are

4 705 bytes of CODE memory
18 bytes of DATA memory (+ 5 absolute )
7 796 bytes of XDATA memory
64 bytes of IDATA memory
8 bits of BIT memory

but I cant add new file.c again and the are error about XDATA.

I use code model Banked

Data model Large

Calling Convention XDATA

and location constant and string in RAM

what should I do in order to optimize 256KB memory in CC2541?

Regards

Tia

  • Hello Tia,
    XDATA memory is equivalent to RAM. CC2541 has 8KB of RAM. The IAR compiler is set to write all constants by default to XDATA. If your strings are constants you can place these in flash instead (CODE memory). This might free up some XDATA memory (RAM) in your application. You can place a constant string in flash like this:
    const char __code text_welcome1[] = "CC2541 PER Test ";
  • Thans for your respons Eirik

    I want display "Hello" in SSD1306 and I choose Code memory to save Constant and string (in General Options setting)

    ISSD1306_Puts("Hello", &Font_7x10, SSD1306_COLOR_BLACK);


    Error[Pe167]: argument of type "char __code *" is incompatible with parameter of type "char *"
    what is mean?
  • Helli Tia,

    You need to convert yours string into a char pointer. Refer to the source code in CC254x Proprietary Mode Packet Error Rate Test (Rev. B)

    /*******************************************************************************
    * @fn           c2xd
    *
    * @brief        Convert code char constant pointer to xdata char constant pointer.
    *
    * @param        const char __code * src :
    *               char __code pointer to "string" constant.
    *
    * @Note:        Due to limited RAM size most of the constants are stored in
    *               CODE space (FLASH). This function convert code constants to
    *               xdata constants for use in writing text to LCD.
    *
    * @return       __xdata char pointer.
    */
    const char* c2xd( const char __code * src ) {
       const char* s;
       // Map the code pointer to the correct __xdata address.
       s = (const char*)(src+0x8000);
       return s;
    }