This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

"automatics require more than 16384 bytes" - What does that mean?

C166+AR166, MCBXC167-Net Board with XC167 Controller.

The Compiler list the following error:
"FIELD.C(89): error C176: 'test': automatics require more than 16384 bytes"
What does that mean? How can i solve this problem?

Thanks in advance!!!

Here is the corresponding function:

void test(void)
{
unsigned char field[288][502];
unsigned char *p_field;
p_field = &field[0][0];

}

  • The auto variable 'field' requires 144576 bytes! For something that big, it's best to allocate it as a static duration data object or as a dynamically allocated data object using malloc/free. Dynamic allocation, ill-advised as it may be, would behave more like an auto variable as far as the data object's lifetime is concerned.

  • Hi John,

    What does that mean?

    It means exactly what it says. The total size of all automatic variables declared within the function exceeds 16K bytes. Automatic is just a fancy word for local non-static. It is easy to see where this limitation comes from. Keil's C166 uses the so called user stack to store automatic variables, and the user stack size is limited to 16K bytes, which in turn is due to the fact that only near addressing is used for the user stack in C166.

    How can i solve this problem?

    If you absolutely have to have a local non-static variable of this size, which I doubt, than there is no way. If you can do with a static local variable, try the following:

    void test(void)
    {
    static unsigned char huge field[288][502];
    unsigned char huge *p_field;
    p_field = &field[0][0];
    }
    

    - mike

  • Hi Mike,
    thanks for your reply. Of course i didn't thought about
    the 16KB Boarder and the different memory models...
    But now i see another problem. My aim is to transfer one Byte
    from the char field to the IO Port3 (P3.0-P3.7) parallel.
    For this i use the PEC triggered by an fast external interrupt
    pin (i.e. Ext.Int0 from pin P2.8 - EX0IN).
    The char field should be located in the external 512KB
    RAM of the MCBXC167-NET Board.
    The Problem is, that the PEC Source Pointer must be the pointer
    p_field. But this is now a 32Bit Pointer and the PEC only
    supports 24Bit Pointers. Furthermore the PEC could only increment
    the highest 8 bits of the Source Pointer and that is not
    enough for the overall field with 288*502 = 144576 values.
    I would very much appreciate if you could give me some hints.
    - John

  • PEC Source Pointer must be the pointer p_field. But this is now a 32Bit Pointer and the PEC only supports 24Bit Pointers.

    What you think is a 32-bit pointer is essentially a 24-bit pointer. The C166 architecture only supports up to 24 bits for memory addressing. The 8 most significant bits of huge and xhuge pointers are not used. But the PEC has other limitations: it cannot cross 64K boundaries and it can be set to transfer 255 bytes at most.
    Of course, in the perfect world all pointers and counters would be at least 32-bit, and we would never have to deal with overflows/underflows/whatever. Well, you have to deal with those limitations yourself. It may involve resetting the PEC every once in a while. Or you can ignore the presence of PEC and use interrupts only.

    - mike

  • Hello,
    right now, i could solve the pointer problem... But i'm still working on the PEC Problem. i couldn't find any solution to cross the segment after the PEC Source Pointer has reached the value SRCP0=0xFFFF.
    A normal Interrupt is not possible because the signals arrive at the external Interrupt Pin P2.8 with 10 MHz. (every 100ns)