In the peripherals configuration for a Flexcomm USART, under "General Configuration," there are two checkboxes, "Enable RX" and "Enable TX." When you mouse over them, the pop-up description says, somewhat redundantly, "Enable Receiver" and "Enable Transmitter," respectively.
The API reference docs say the same thing. There's a definition of the type usart_config_t which includes boolean fields enableRx and enableTx and the non-helpful doxygen comments (see fsl_usart.h) say "Enable RX" and Enable TX," respectively.
So pardon me if I thought that these fields controlled whether the transmit side and the receive side of the USART could be wholly disabled or enabled. The code in fsl_usart.c disagrees!
In the USART_Init() function we see:
if (config->enableTx)
{
/* empty and enable txFIFO */
base->FIFOCFG |= USART_FIFOCFG_EMPTYTX_MASK | USART_FIFOCFG_ENABLETX_MASK;
/* setup trigger level */
base->FIFOTRIG &= ~(USART_FIFOTRIG_TXLVL_MASK);
base->FIFOTRIG |= USART_FIFOTRIG_TXLVL(config->txWatermark);
/* enable trigger interrupt */
base->FIFOTRIG |= USART_FIFOTRIG_TXLVLENA_MASK;
}
/* empty and enable rxFIFO */
if (config->enableRx)
{
base->FIFOCFG |= USART_FIFOCFG_EMPTYRX_MASK | USART_FIFOCFG_ENABLERX_MASK;
/* setup trigger level */
base->FIFOTRIG &= ~(USART_FIFOTRIG_RXLVL_MASK);
base->FIFOTRIG |= USART_FIFOTRIG_RXLVL(config->rxWatermark);
/* enable trigger interrupt */
base->FIFOTRIG |= USART_FIFOTRIG_RXLVLENA_MASK;
}
So the two controls determine whether the FIFOs are enabled, not whether the entire transmit or receive functions are enabled.
Can someone in the documentation group fix this? It needs to be fixed in the source code as well as the MCUXpresso configuration tool.
Solved! Go to Solution.
Andy.
I got feedback from SDK team. This issue will be fixed in next released.
Thanks!
Jun Zhang
Hi Andy,
To check this issue, we need to know:
- your chip part number
- MCUXpresso IDE version
- ""Enable RX" and "Enable TX." When you mouse over them, the pop-up description says, somewhat redundantly,", I tried with my LPC546xx sdk2.7.1 project, I didn't see this problem, could you please send me a video about this?
- please send me your demo project, and mention how I can reproduce your issue with your project?
Thanks,
Jun Zhang
I'm using MCUXpresso IDE v11.1.1 [Build 3241] [2020-03-02], which I believe is the latest.
const usart_config_t MIDIUART_config = {
.baudRate_Bps = 31250,
.syncMode = kUSART_SyncModeDisabled,
.parityMode = kUSART_ParityDisabled,
.stopBitCount = kUSART_OneStopBit,
.bitCountPerChar = kUSART_8BitsPerChar,
.loopback = false,
.txWatermark = kUSART_TxFifo0,
.rxWatermark = kUSART_RxFifo1,
.enableRx = true, // set to true if checkbox checked
.enableTx = false, // set to false if checkbox cleared
.clockPolarity = kUSART_RxSampleOnFallingEdge,
.enableContinuousSCLK = false
};
So the point of all of this is that the documentation is not correct. The documentation, the name of the member variables and the config tool itself imply that checking the box in the configurator (or setting the const initializers in the code) enables or disables the receiver or transmitter function, which is wrong. This controls whether the FIFO in the function is enabled or not.
Hi Andy Peters
Thanks for reporting it.
I got your point. I will escalate it to SDK development to request fix.
Thanks for bringing the problem to our attention.
BR,
Jun Zhang
Andy.
I got feedback from SDK team. This issue will be fixed in next released.
Thanks!
Jun Zhang