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.
Hello,
I have the issue with UART4 using with DMA.
I have configured it as follows:
void configureUARTinterface(void)
{
// UART initialization
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);
//
// Wait for the UART0 module to be ready.
//
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_UART4))
{
}
//
// Set GPIO PK0 and PK1 as UART pins.
//
MAP_GPIOPinConfigure(GPIO_PK0_U4RX);
MAP_GPIOPinConfigure(GPIO_PK1_U4TX);
MAP_GPIOPinTypeUART(GPIO_PORTK_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Configure the UART for 1.000.000, 8-N-1 operation.
//
MAP_UARTConfigSetExpClk(UART4_BASE, g_ui32SysClock, 1000000,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
MAP_UARTClockSourceSet(UART4_BASE, UART_CLOCK_SYSTEM);
//
// Set both the TX and RX trigger thresholds to 4. This will be used by
// the uDMA controller to signal when more data should be transferred. The
// uDMA TX and RX channels will be configured so that it can transfer 4
// bytes in a burst when the UART is ready to transfer more data.
//
MAP_UARTFIFOLevelSet(UART4_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);
// Enable FIFO for the UART1
MAP_UARTFIFOEnable(UART4_BASE);
//
// Enable the UART for operation, and enable the uDMA interface for both TX
// and RX channels.
//
MAP_UARTEnable(UART4_BASE);
// uDMA initialization
MAP_UARTDMAEnable(UART4_BASE, UART_DMA_TX);
MAP_UARTDMAEnable(UART4_BASE, UART_DMA_RX);
MAP_uDMAChannelAssign(UDMA_CH18_UART4RX);
MAP_uDMAChannelAssign(UDMA_CH19_UART4TX);
MAP_uDMAChannelAttributeDisable(UDMA_CH18_UART4RX,
UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
MAP_uDMAChannelAttributeEnable(UDMA_CH18_UART4RX, UDMA_ATTR_USEBURST);
MAP_uDMAChannelAttributeDisable(UDMA_CH19_UART4TX,
UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
MAP_uDMAChannelAttributeEnable(UDMA_CH19_UART4TX, UDMA_ATTR_USEBURST);
MAP_uDMAChannelControlSet(UDMA_CH18_UART4RX | UDMA_PRI_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
UDMA_ARB_4);
MAP_uDMAChannelControlSet(UDMA_CH19_UART4TX | UDMA_PRI_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE |
UDMA_ARB_4);
}
With following function I start a DMA transfer to transmit an UART message and set the DMA transfer when an UART message is received.
void sendMessageToMCU(E_MCU_Messages messageType)
{
uint8_t i;
switch(messageType)
{
case eMCU_MESSAGES_SET_VALUES_AND_POLL:
{
memset(uartTXBuffer, 0, sizeof(uartTXBuffer));
uartTXBuffer[0] = 0x01;
memcpy(&uartTXBuffer[1], &SBS10_MCU_Status, sizeof(uSBS10_MCU_Status));
ui32CRC32Result = MAP_CRCDataProcess(CCM0_BASE, (uint32_t *)uartTXBuffer, sizeof(uSBS10_MCU_Status) + 1, false);
memcpy(&uartTXBuffer[sizeof(uSBS10_MCU_Status) + 1], &ui32CRC32Result, 2);
(void)SLIPP_eStartEncode(&tSLIPSendBuffer);
for (i = 0; i < sizeof(uSBS10_MCU_Status) + 3; i++)
{
(void)SLIPP_eEncode(&tSLIPSendBuffer, uartTXBuffer[i]);
}
(void)SLIPP_eEndEncoding(&tSLIPSendBuffer);
MAP_uDMAChannelTransferSet(UDMA_CH19_UART4TX,
UDMA_MODE_BASIC, tSLIPSendBuffer.pui8Buffer,
(void *)(UART4_BASE + UART_O_DR),
tSLIPSendBuffer.ui32BufferPointer);
}
break;
default:
break;
}
MAP_uDMAChannelEnable(UDMA_CH19_UART4TX);
MAP_uDMAChannelTransferSet(UDMA_CH18_UART4RX,
UDMA_MODE_BASIC,
(void *)(UART4_BASE + UART_O_DR),
uartRXBuffer, sizeof(uartRXBuffer));
MAP_uDMAChannelEnable(UDMA_CH18_UART4RX);
//
// Enable the UART DMA TX/RX interrupts.
//
//MAP_UARTIntEnable(UART4_BASE, UART_INT_RX | UART_INT_RT);
//MAP_IntEnable(INT_UART4);
HWREG(UART4_BASE + UART_O_ICR) = UART_ICR_RTIC;
HWREG(UART4_BASE + UART_O_ICR) = UART_ICR_RXIC;
}
My problem is, after that configuration and after sending (calling the second function), the controller is permamently calling the UART4 interrupt handler and no usual program flow is possible,
Thank you for help ...
Sorry,
the interrupt only occurs when they are enabled, so the lines
//MAP_UARTIntEnable(UART4_BASE, UART_INT_RX | UART_INT_RT);
//MAP_IntEnable(INT_UART4);
have to of course uncommented
MAP_UARTIntEnable(UART4_BASE, UART_INT_RX | UART_INT_RT);
MAP_IntEnable(INT_UART4);
So you see, when I comment these two lines, the program flow of the controller is "normal"
Hi,
I think the problem is due to the below line of code. Did you reference the udma_demo example in <TivaWare_Installation>/examples/boards/ek-tm4c1294xl/udma_demo. In this example, it uses uDMA to transfer data from UART1 but you can modify it for UART4.
You need to change:
From:
MAP_UARTIntEnable(UART4_BASE, UART_INT_RX | UART_INT_RT);
To:
MAP_UARTIntEnable(UART4_BASE, UART_INT_DMARX | UART_INT_DMATX);