Tool/software: TI C/C++ Compiler
In what looks to be the latest version f Starterware 2.1.1.0 dated 2013, there is a mistake in UART.C:
#define UART_IIR_FCR_MIRROR_MASK (0x000000c0U)
#define UART_IIR_FCR_MIRROR (0x000000C0u)
#define UART_IIR_FCR_MIRROR_SHIFT (0x00000006u)
uint32_t UARTIsFifoEnabled(uint32_t baseAddr)
{
uint16_t lcrRegVal = 0U;
uint32_t status = FALSE;
/* Switch to Register Operational Mode of operation. */
lcrRegVal = UARTSetRegAccessMode(baseAddr, UART_REG_ACCESS_MODE_OPER);
if(UART_IIR_FCR_MIRROR_MASK == HW_RD_FIELD16((baseAddr + UART_IIR), UART_IIR_FCR_MIRROR))
{
status = TRUE;
}
/* Restoring the value of LCR. */
HW_WR_REG16(baseAddr + UART_LCR, lcrRegVal);
return status;
}
The MACRO will retrieve the FCR Mirror bits from the IIR register and then mask them with 0xC0, then sift the result right by 6 bits to place the two bits in to the least significant bits, then the code checks to see if the result is 0xC0 which is incorrect. The code should look more like this:
if(0 != HW_RD_FIELD16((baseAddr + UART_IIR), UART_IIR_FCR_MIRROR))
The desire is to test the two FCI Mirror bits to see if they are either 00 or 11. The code as provided by TI always returns FALSE when someone calls the API to determine if their UART's FIFO is enabled or not.
I've fixed it in my company's copy of Starterware and because this is the second issue we have had (the first one was MACRO expansion of arguments not wrapped in parenthesis)
#define EDMA_TPCC_DMAQNUM(n) ((uint32_t)0x240U + (n * 0x4U)) <-- n not wrapped (n)
HW_WR_FIELD32(baseAddr + EDMA_TPCC_DMAQNUM(chNum >> 3U),
EDMA_TPCC_DMAQNUM_E1, queueNum);
We are having one of our software engineers go through the Starterware modules looking for any other issues. This isn't a request for assistance, it's just a request that TI correct the function in future versions of Starterware.
Thanks!