This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TINA/Spice/TM4C1294NCPDT: Initializing Arrays

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: TINA-TI

Tool/software: TINA-TI or Spice Models

Hello,

I'm programming with keil c version 5.26. I use TivaWare_C_Series-2.1.4.178 for my code. When I declare the array as follows:

uint16_t length = 9+2*Q_add;
uint8_t buffer[length];

I ran the keil debugger c, then hit run, but keil immediately stopped debugging. I use the J-link OB STM32 loaded circuit.

Instead I use the following code then the debugger runs normally

uint16_t length = 9+2*Q_add;
uint8_t buffer[100];

  • Hello Vu,

    Your query is really specific to Keil and we aren't the company that makes Keil, so unfortunately this is not really a topic we can help with. If the issue was CCS related (a TI made compiler) that would be a different story, but for Keil I really don't have any means to comment on why one method works and the other doesn't as to me I would have expected both to work just fine. I would recommend reaching out to Keil support to get some understanding on why that doesn't work.
  • The first method declares a Variable-length array (VLA).

    This manual page indicates that the array is allocated on the heap - http://www.keil.com/support/man/docs/armcc/armcc_chr1359124950297.htm

    Therefore, the failure might be due to insufficient heap.

    I don't use the Keil compiler, but have seen a similar issue with the TI compiler where insufficient heap space can cause a failure to allocate a VLA.