Tool/software: TI C/C++ Compiler
Why are static variables not being initiated to 0x0 by C++ definition of a static variable?
How to initiate CCS array[] (all cells) to 0x0? Classic C++ method to initiate array cells via empty braces {} declaring are marked as error when compiled.
CCS defined array are being limited to 8 bytes pointer index that can not search beyond the argument value set by (char) length, should be 255 bytes not bits. CCS debug shows the argument pointer only fills the array cells from bytes 0-7 via the input buffer assignment. Attempting to ever flush the passing buffer or the argument value after index value is found fails to return the pfn command structure defined by (argc, argv[]). That is especially true when hexadecimal values passed to char, CCS9.1 debug element array value often changes 0xff to '0' as other char are entering the F6 stepped array buffer. Very confusing when the displayed value suddenly changes like that and often differs from char that was input from FIFO.
Serial character passing of buffer contents via (char) into *char argument pointer of an called function produce truncated buffer lengths. Sometimes the full length of FIFO input stream of the callers array buffer is passed to the called function - more often not no matter the timeout length set in the while loop caller from a 5ms GPTM interval.
This is a small array buffer pointed to by static integer [I] and incremented via (for loop) as it passes char into the next called function to test command argument values. The buffer is often truncated when being passed to the called function being much shorter by several bytes than the UART FIFO (for [I]) loop RX data being buffered. The POP function of array value from a FIFO randomly stumbles. However the while loop PUSH function from array to FIFO is working great via same GPTM 5ms while calls. Seemingly this is a Thumb instruction execution issue on back to back Reads of UARTDR register via (HWREG for blocking loop shown below). The compiler 18.12.3.LTS is responsible to produce the correct tool chain Thumb instructions in this case as not to stumble during loading array BUFFER via POP of read sensitive register UARTDR.
#define BUFFER 20
char MyArray[BUFFER] = {};
// Called from UART receive interrupt:
/* Process commands from UART RX data
* and return events with 33ms timeout */
while(GetCmd(BUFFER, (SYSTEM_CLOCK / 30)));
int
GetCmd(char *buffer, uint32_t timeout)
{
static char *Cchar;
Cchar = buffer;
static uintptr_t i;
int ret = 0;
static uint32_t Timeout;
/* Timeout for getting RXD FIFO bytes */
for(Timeout = 0; Timeout < timeout; Timeout++)
{
/* Load RX data elements */
for(i = 0; i < 32; i++)
//while (len != '\0')
{
//len = strlen(Cchar);
/* Check if receiver is Not full, NonBlocking
* characters are received into FIFO */
if(!(HWREG(UART2_BASE + UART_O_FR) & UART_FR_RXFE))
{
// Cchar[i] = UARTCharGetBlocking(UART2_BASE) & 0xFF;//
Cchar[i] = (HWREG(UART2_BASE + UART_O_DR));
/* FIFO not empty */
ret = 1;
}
/* The RX FIFO is full */
if (i >= 32)
{
/* Scan the argument buffer for commands
* and process only valid command/s */
ret = CheckNexCommands();
/* Playback the receiver buffer */
UARTprintf(">>Playback RXD\n");
i=0;
while(i < 32)
{
/* System clock 8.33ns time, 208us delay */
SysCtlDelay(SYSTEM_CLOCK / 4800);
/* Print 0x70 return variable name */
UARTprintf("Rx:%c :%x\n", CcRxBuff[i], CcRxBuff[i]);
i++;
}
return(ret);
}
/* Print 0x70 return variable name */
UARTprintf("Rx:%c %x\n", Cchar[i], Cchar[i]);
/* Scan the input buffer for commands
* Process valid command/s */
ret = (CheckForCommands());
}
}
return(ret);
}

