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.

Double to Char

Other Parts Discussed in Thread: MSP430FR5739, MSP-EXP430FR5739

Hi,

I am using MSP430FR5739 and i need to convert double "51.11635910984" to char. when i use sprintf function it says "#10099-D program will not fit into". RAM is not enough for this operation and i want to use FRAM.

So, I tried to change the size of FRAM in the linker command file. However, a problem was occured when i debug the code not in build.


//FRAM_DATA : origin = 0xC200, length = 0x0BE0                       //original
//FRAM : origin = 0xCDE0, length = 0x31A0                                   //original

FRAM_DATA : origin = 0x2000, length = 0x0BE0                       // i changed
FRAM : origin = 0x3000, length = 0xC000                                   // i changed

The problem output is 

"MSP430: File Loader: Data verification failed at address 0x00003000 Please verify target memory and memory map.
MSP430: GEL: File: C:\WebBasic\GET_v.1.7\source\apps\MSP-EXP430FR5739\webserver\CCS\webserver\Debug\webserver.out: a data verification error occurred, file load failed."

  • Burak DERYA said:
    So, I tried to change the size of FRAM in the linker command file. However, a problem was occured when i debug the code not in build.

    //FRAM_DATA : origin = 0xC200, length = 0x0BE0                       //original
    //FRAM : origin = 0xCDE0, length = 0x31A0                                   //original

    FRAM_DATA : origin = 0x2000, length = 0x0BE0                       // i changed
    FRAM : origin = 0x3000, length = 0xC000                                   // i changed

    The problem output is 

    "MSP430: File Loader: Data verification failed at address 0x00003000 Please verify target memory and memory map.
    MSP430: GEL: File: C:\WebBasic\GET_v.1.7\source\apps\MSP-EXP430FR5739\webserver\CCS\webserver\Debug\webserver.out: a data verification error occurred, file load failed."

    The Memory Organization section of the MSP430FR5739 datasheet shows:

     - 15.5Kb of FRAM memory for code (from 0xC200 to 0xFF7F) and interrupt vectors (from 0xFF80 to 0xFFFF)

     - 256b of FRAM information memory from 0x1800 to 0x18FF

     - 1Kb of RAM from 0x1C00 to 0x1FFF

     The changes to the linker command file said there was FRAM from 0x3000 to 0xEFFF and FRAM_DATA from 0x2000 to 0x2BDF. This will cause the linker to try and store code where there is no FRAM, leading to the data verification errors.

  • You are rigth i made it wrong and understood what is wrong here. I did the linker command file original format. Now i would like to convert the double to char with sprintf function or something else. How can i convert the data without any RAM error.

  • Burak DERYA said:
    Now i would like to convert the double to char with sprintf function or something else. How can i convert the data without any RAM error.

    Looking at the linker command file you can move variable sections into the READ_WRITE_MEMORY group, which would then allocate the variables in FRAM rather than RAM. e.g. the default linker command file places the .sysmem section for dynamic memory allocation in FRAM rather than RAM.

    Is it possible to post the linker .map file to see how large the variables are .vs. the code?

    On a MSP430FR5739 using sprintf with full floating point support, and compiling with EABI output format to get double support, takes ~12.5Kb of the available 15.5Kb of FRAM so yoy will probably have to try a different approach to get everything to fit into the available memory.

  • Use this instead of sprintf and save memory,

    extract the integer part first by doing

    int integer = (int)float;

    then ,

    void MyReverStr(uint8_t *OutArray)
    {
      uint32_t CntBeg = 0,CntEnd = 0;
      uint8_t TempChar;

      for(CntBeg = 0,CntEnd=strlen((char const*)OutArray)-1;CntBeg<CntEnd;CntBeg++,CntEnd--)
      {
        TempChar = OutArray[CntBeg];
        OutArray[CntBeg] = OutArray[CntEnd];
        OutArray[CntEnd] = TempChar;
      }
    }

    uint8_t MyItoa(uint32_t Num, uint8_t *OutArray)
    {
      uint32_t Count = 0;

      do{   //Storing in the reverse order
        OutArray[Count++] = Num%10 + '0';
      }while((Num/=10) > 0);
      OutArray[Count] = '\0';
      MyReverStr(OutArray);
      return Count;
    }

    Now extract the fraction and append it with integer string.

    void FractPartConv(float FractPart, uint8_t *DestStrn)
    {
      uint8_t ConvCnt,FractDig;

      for(ConvCnt = 0;ConvCnt<5;ConvCnt++)
      {
        FractPart *= 10;
        FractDig = (uint8_t)FractPart;
          if(FractDig < 1)
        {
              DestStrn[ConvCnt] = '0';
        }
          else
        {
              FractPart -= FractDig;
              DestStrn[ConvCnt] = FractDig + '0';
        }
      }
    }

    Hope this helps u.

  • Can this be modified to work with a double?

**Attention** This is a public forum