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 all,
I would like to consult whit you according a issue, which I got last few days. I use uart_dma SDK example and I try to implement UART interrupt. My purpose is: I want to get an interrupt each time when I receive one byte. If it possible purpose and how can I get it? This example use uDMA and enableing of UART FIFO buffers. In UARTIFLS register
the setting about receive interrupt are as follow
0h -> 8 bytes
1h -> 10 bytes
2h -> 14 bytes
3h -> 17 bytes
4h -> 20 bytes
(if I'm wrong let me know). So if I set 0h in RXIFLSEL, I will get interrupt when I receive 8 bytes in my RX FIFO buffer, right? How can I get interrupt, when I get one byte? Thanks in advance!
Best regards,
Sergey.
Hi Sergey,
You can use UART with interrupts and no DMA for your use case.
UART has two FIFOs (TX and RX) each 16 bytes deep and it can generate interrupts at at different levels i.e at 2, 4, 8, 12 and 14 bytes.
In addition, for receive it can generate additional interrupt for Receive Timeout, this is generated if the RX FIFO is not empty and is not read out before the timeout period.
You can also opt to disable the FIFO, in which case the UART will act as if FIFO depth is 1 byte.
For more details please refer to cc3200 TRM section 6.2.3.3.
Thanks and Regards,
Praveen
Thanks Praveen!
What is the risk to lose some data, during the transfer, when disable FIFO buffer? I will use UART on different speed transfer, and I have started to implement a ring buffer which I will attache to receiving data. Is there a way when a interrupt occurs I have a chance to catch all receiving data?
Thanks and Regards,
Sergey.
Sergey,
Loosing data will depend on your end application like how free CPU is to service the interrupt. If there is a large amount of data which you want receive/store and then process then its better you opt for DMA.
Can you post some more details of your application ?
For the second part of your question, once you get an interrupt you can loop inside the interrupt handler to read out all the data in the FIFO.
For example:
int UARTIntHandler()
{
.......
while( ( ulData = UARTCharGetNonBlocking(UARTA0_BASE) ) != -1 )
{
// Put the ulData into your buffer
}
........
}
Regards,
Praveen
Hi Kaushal,
thanks about you answer! I found a solution about this issue.
Regards Sergey!
Remove your MAP_UARTDMADisable and try again. DMA is disabled on default. And recheck your MAP_UARTFIFODisable if It's realy disable FIFO's. Because MAP_UARTConfigSetExpClk in its low levels enable FIFO's and if you MAP_UARTFIFODisable doesn't do this.....this can be the issue.
Hello all,
Actually i have written the code as follows:
#define CONSOLE1 UARTA1_BASE
#define CONSOLE_PERIPH1 PRCM_UARTA1
//UART-1 Initialization
MAP_PRCMPeripheralReset(CONSOLE_PERIPH1);
MAP_UARTConfigSetExpClk(CONSOLE1,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH1),
UART_BAUD_RATE,(UART_CONFIG_WLEN_8 |
UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
MAP_UARTFIFODisable(CONSOLE1); //disable fifo
/here we will configure the UART-1 interrupt based communication
MAP_UARTIntRegister(CONSOLE1,UART1_Handler); //enable interrupts
MAP_UARTIntEnable(CONSOLE1,UART_INT_DMARX | UART_INT_DMATX);
And the Handler is written as:
void UART1_Handler()
{
while(( UARTData = UARTCharGetNonBlocking(CONSOLE1) ) != -1)
{
UARTDataBuffer[UARTDataCount] = UARTData;
UARTDataCount++;
if(UARTDataCount > 10)
{UARTDataFlag = 1;}
}
}
Can anybody please verify if this is correct, or any changes to be done ??
That will be really helpful.
Thank you in advance.
Warm regards,
Abhishek.