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.

Write data to RAM, MSP430AFE

Other Parts Discussed in Thread: MSP430AFE253

Sorry guys, but I'm not that fit with uC programming. In the example code of MSP430AFE253 I could not find any program how to write data into RAM. Does any body has the code for this, or is there any example code of another MS430 that could work with AFE253?

Thx

  • Hello,

     

    did you look at:

    http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?sectionId=96&tabId=1468

     

    There are a lot of code-examples, whether they will fit Youre application or even Processor is not that important, since all the MSPs are quite similar.

     

    So I hope you will find some code-structures that help You to continue Youre struggle :)

     

    And in the FamilyUserGuide of Youre processor  there should be detailed information on how to handle Flash writing and erasing.

     

    Greetings, Seb

  • Thx Seb for ur reply. I'm not sure if it is the same way to write data to RAM as to flash or not, because there is already a sample code for flash for the msp430...

  • Sorry i did read FLASH but you meant RAM.

     

    Usually in the linker file( something like xxxx.cmd) based in the Project folder of the CCS, if you might use that compiler. there are all the different regions of memory.

    And in the FamilyUserGuide there is stated which codesegments, like variables or constants, are placed in which memory like FLASH or RAM.

     

    it might look something like this:

    SECTIONS
    {
        .bss       : {} > RAM                /* GLOBAL & STATIC VARS              */
        .sysmem    : {} > RAM                /* DYNAMIC MEMORY ALLOCATION AREA    */
        .stack     : {} > RAM (HIGH)         /* SOFTWARE SYSTEM STACK             */

        .text      : {}>> FLASH | FLASH2     /* CODE                              */
        .text:_isr : {} > FLASH              /* ISR CODE SPACE                    */
        .cinit     : {} > FLASH              /* INITIALIZATION TABLES             */
    //#ifdef (__LARGE_DATA_MODEL__)
        .const     : {} > FLASH | FLASH2     /* CONSTANT DATA                     */
    //#else
    //    .const     : {} > FLASH              /* CONSTANT DATA                     */
    //#endif
        .cio       : {} > RAM                /* C I/O BUFFER                      */

        .pinit     : {} > FLASH              /* C++ CONSTRUCTOR TABLES            */

     

    So hereby you know in which segments what kind of code is stored.

     

    Now my knowledge is at end almost :) There is supposed to be a commant with which You can define a function or a segment to a certain memory spot like .text or .bss or whatever you like, but i dont know the exact command, perhaps someone else could help you out with this.

     

    And normally youre whole programm code will be stored in RAM, whereas all constans will be stored into FLASH.

    Hope that will help you a little more.

  • Thank you Seb for your answer.

    Actually all what I want to do is, to save data out of an ADC to RAM. And since the RAM is not that big, I will move the data to the flash later on...

     

  • I have just read in the family data sheet:

    The direct memory access (DMA) controller transfers data from one address to another, without CPU
    intervention, across the entire address range. For example, the DMA controller can move data from the
    ADC12 conversion memory to RAM.

    Is it also possible to transfer the data directly from SD16 ADC to the RAM or flash?

  • MSP430-Beginner said:
    Is it also possible to transfer the data directly from SD16 ADC to the RAM or flash?

     

    As far as i know, i never used that for myself, this is really usefull for Low Power mode applications.

    Because You dont have to wake up the CPU and are still able to store ADC conversion results, which you get in an still active Interrupt Routine, in the RAM.

     

    I guess there are some commands or registers with which You can manage the wished behaviour.

  • MSP430-Beginner said:
    In the example code of MSP430AFE253 I could not find any program how to write data into RAM.

    Because it is plain C.

    Teh MSP has a unified addressign range. Registers, ram, flash, all are in teh same address range and the processor can use them in any combination.

    If you want to explicitely write something to a memory location, then you need to know where on your MSP ram is (see datasheet). Then in C, define a pointer to your preferred datatype you want to write into ram, assign it the address of the ram location you want to write your data to, and just write your data using the pointer.

    unsigned char * rampointer = 0x1000; // rampointer now points to ram at 0x1000.

    *rampointer = 1; // writes 1 to 0x1000
    rampointer[0]=2; // writes 2 to 0x1000
    rampointer[1]=3; // writes 3 to 0x1001 (address +1 since the size of a char is 1 byte. If rampointer were an unsigned int *, the index 1 would be 0x1002/0x1003

    in assembly langage it is similar.

    Alternatively, if you just want to store th data somewhere in ram where you can access it later, you can jus tlet the compiler do the job. Define a global variable and you're done. the linker will automatically pick a location in ram for our variable and change the generated code so that this location is used whenever you read or write the variable. Based on your porject settings (target MSp type), the linker knows where your MSP has its ram area.

**Attention** This is a public forum