Saving string in 8051 RAM (using C)

Discussion in 'Embedded Systems and Microcontrollers' started by Dritech, May 14, 2015.

  1. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Hi all,

    I have the following line of code which I need to store in the IDATA memory.

    char code *text_to_compare = "Tesing";

    How can I achieve this please?
    I found examples but they are all in assembly language.
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    char text_to_compare[] = "Testing";
     
  3. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Thanks for the reply. Is there a way to start from memory location 90hex ?
     
  4. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Any suggestions please?
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    We need to know which microcontroller and which compiler (IDE).
     
  6. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Thanks for the reply. I am using the 8051 with the C51 compiler.
     
  7. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    Specify both brand names.

    Or you can try:

    char text_to_compare[] = "Testing" @ 0x0090;

    char text_to_compare[] = "Testing" at 0x0090;
     
  8. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Unfortunately none of the above worked. If I remove the @0x0090 it is compiling normally and saving in IDATA, but not starting from 90H.
    The micro-controller brand is Atmel and the compiler is Keil.
    Thanks.
     
  9. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    Try:

    char text_to_compare[] = "Testing" _at_ 0x0090;
     
  10. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Unfortunately that did not work either.
     
  11. nitro2

    New Member

    Nov 6, 2011
    1
    0
    Is it ok?
    Code (Text):
    1. char *str_pt ;
    2. str_pt = (char*) 0x0090;
    3. str_pt[0] = 'T' ;
    4. str_pt[1] = 'e' ;
    5. str_pt[2] = 's' ;
    6. str_pt[3] = 't' ;
    7. str_pt[4] = '\0';
    if you only want to declare it in idata:
    char idata str_pt[] = "Test";
     
Loading...