Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create big buffer on a pic18f with microchip c18 compiler

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?

like image 584
acemtp Avatar asked Jun 06 '10 10:06

acemtp


1 Answers

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...)

like image 84
Wim Avatar answered Sep 30 '22 10:09

Wim