[Tinyos-help] program memory v data memory

Neil Hancock neilh10tos at biomonitors.com
Mon Mar 28 21:48:50 PST 2005

Thanks for the pointers Vlasios - gotit.
It is the only place I see it in the code base so in case anybody else gets
interested in storing constants in progspace and then copying them out here
it is -;


static const prog_uchar ContStr[] =
                         "\n\rConstant text1"
                         "\n\r text2 abcdefghijklmnopqrstuvw"
                         "\n\r text3 abcdefghijklmnopqrstuvw"

task void constDemo() {
    call PrintUtils.printPm(ConstStr);


  command int printPm(const prog_uchar * str);

command int PrintUtils.printPm ( const prog_uchar *str )
  int buf_lp;
  int chr_cnt = 0;
  uint8_t cont_prnt;;
  uint8_t outStr[PRINTPM_MAX_SIZE+1];

  cont_prnt = 1;
  do {
    for (buf_lp=0; buf_lp < PRINTPM_MAX_SIZE-1; buf_lp++) {
      if (0 == (outStr[buf_lp] = PRG_RDB(str++))) {
        cont_prnt = 0;
    call SimpleQue.send(outStr);
    chr_cnt += buf_lp;
  } while ((cont_prnt != 0) && (chr_cnt < SIMPLEQUE_BUFFER_SIZE));
  return chr_cnt;
} // end printPm

-----Original Message-----
From: Vlasios Tsiatsis [mailto:tsiatsis at ee.ucla.edu]
Sent: Monday, March 28, 2005 2:54 PM
To: Neil Hancock
Cc: tinyos-help at now.cs.berkeley.edu
Subject: Re: [Tinyos-help] program memory v data memory

Take a look ato tinyos-1.x/tos/platform/mica2/CC1000Const.h to see exactly
how constants on the flash memory are declared in the context of TinyOS
code. Search for "CC1K_LPL_PreambleLength".

I hope this helps,

On Mon, 28 Mar 2005, Neil Hancock wrote:

> Hi
> I'm having a bit of an issue with the separated data and program space of
> the ATmega128.
> The issues is how to get constants/tables and const strings in program
> memory and not in data memory.
> Having 128K flash, and 4K ram in an ATMega128 does mean that the ANSI 'C'
> concept of consts in data memory is a tiny bit of a problem.
> 'C' doesn't overload to figure out what it should do between a const
> memory and data memory, I'm trying to use some of the concepts/hacks from
> AVR-Lib, which uses macros.
>   *( http://savannah.nongnu.org/download/avr-libc/ )->
> (avr-libc-1.2.3.tar.gz)-> pgmspace.h
> nesC isn't very happy with (const char PROG_MEM *) but only warns and
> doesn't reject it. However compiling with "make pc" does cause it to break
> the simulator which isn't very useful.
> Anybody coming up with an easier solution in nesC for the ATmega128.
>   thanks
>      Neil
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-help

More information about the Tinyos-help mailing list