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.

CC3200 UART interrupt implementation

Other Parts Discussed in Thread: CC3200

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 Sergey,

    Let us know if you have any more query. 

  • Hi Kaushal,

    thanks about you answer! I found a solution about this issue.

    Regards Sergey!

  • Hi Sergey, how are you?

    Do you have any updates on this? I'm also trying to generate an interrupt on every byte received. How did you manage to do it?

    Thanks and regards, Matias.
  • Hi Matias,
    you must disable FIFO buffers of the UART.
  • Hi Sergey, thanks for your reply!

    I already disabled the fifo but this is still not working. Is the order you initialize the uart important? My init function looks like this:

    MAP_PRCMPeripheralClkEnable(UART1_BASE, PRCM_RUN_MODE_CLK); //Start clock

    MAP_UARTConfigSetExpClk(UART1_BASE,MAP_PRCMPeripheralClockGet(_ZIGBEE_UART_ID),
    _ZIGBEE_UART_BAUDRATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); //configure

    MAP_UARTDMADisable(UART1_BASE,UART_DMA_RX+UART_DMA_TX+UART_DMA_ERR_RXSTOP); //disable dma
    MAP_UARTFIFODisable(UART1_BASE); //disable fifo

    MAP_UARTIntRegister(UART1_BASE,UART1_Handler); //enable interrupts
    MAP_UARTIntEnable(UART1_BASE,UART_INT_FLAGS);

    Thanks a lot and apreciate your help.
    Cheers,
  • 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.

  • Hi Sergei,
    I am also working on the same thing.
    Can you post your configuration code for reference ??
    That would be very helpful.

    Warm regards,
    Abhishek.
  • 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.

  • Hello all,
    I am successful in generating the necessary code for my application and my issue stands resolved.

    Thank you all for your help and support.

    Warm regards,
    Abhishek.