Create big buffer on a pic18f with microchip c18 compiler
Asked Answered
M

1

6

Using Microchip C18 compiler with a pic18f, I want to create a "big" buffer of 3000 bytes in the program data space.

If i put this in the main() (on stack):

char tab[127];

I have this error:

Error [1300] stack frame too large

If I put it in global, I have this error:

Error - section '.udata_main.o' can not fit the section. Section '.udata_main.o' length=0x0000007f

How to create a big buffer? Do you have tutorial on how to manage big buffer on pic18f with c18?

Misdeem answered 6/6, 2010 at 10:32 Comment(0)
R
2

Here's a tutorial on exactly this: http://www.dwengo.org/tips-tricks/large-variables

Basically, you declare your variable in a special section, and a pointer to it in the default section:

  #pragma udata DATA // section DATA
  int large_table[768];

  #pragma udata // return to default section
  int *table_ptr = &large_table[0];

Next, you update the linker script to define the large section by adding something like this:

DATABANK   NAME=data      START=0x200          END=0x7FF          PROTECTED
SECTION    NAME=DATA      RAM=data

Note that there usually isn't any unmapped memory in which you can just put your DATA section, but the USB buffers are usually my first choice to canibalize (unless you need USB in the same project of course...)

Rhododendron answered 6/6, 2010 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.