Post Go back to editing

BF706 Uart Rx interrupt handler problem



    I'm writing uart sample code for test.

    I'm using BF706 chip and trying to use uart0 and now I can send data via uart0 and have an issue while I'm getting data via uart rx interrupt.

    I have searched here and found reference code I can try but it's not working as I expected.

    What I referred is below link and I copied uart rx handler code from here.

    When I install uart_rx_interrupt, I could get interrupt but keep getting even though there is no uart transfer so I have no idea how to clear art rx flag.

    If I disable "adi_int_InstallHandler(INTR_UART0_STAT, Uart0Interrupt, NULL, true);" at UartInit(), I could see uart messages coming out via PC terminal so t's working.

    If I enable  "adi_int_InstallHandler(INTR_UART0_STAT, Uart0Interrupt, NULL, true);" at UartInit(), I could not see any message coming out.

    If I trace code via jtag, I could see that after install handler, handler keep posted so couldn't get next line of code.

    I think I missed something what I should do but not sure what I missed.

    So could some help how to get uart rx interrupt handler whenever I send data from PC?


    void Uart0Interrupt(uint32_t iid, void* handlerArg)
        uint32_t stat = *pREG_UART0_STAT;
        uint32_t intV = *pREG_UART0_IMSK_SET;


        rxBuf[rxCount] = *pREG_UART0_RBR;

        if( (rxBuf[rxCount] == '\r') || (rxBuf[rxCount] == '\n') )
            memcpy(rxBuf, uartRxBuf, rxCount);
            bUartRxFlag = true;

    if(rxCount >= (UART_RX_BUFF_LEN - 1))
    rxCount = 0;

    void UartInit(uint32_t uartNum)
    /* open the UART driver in Tx mode only */
    adi_uart_Open(uartNum, ADI_UART_DIR_BIDIRECTION, driverMemory, ADI_UART_BIDIR_DMA_MEMORY_SIZE, &hUartDevice);
    adi_uart_SetMode(hUartDevice, ADI_UART_MODE_UART);
    adi_uart_SetBaudRate(hUartDevice, 115200);
    adi_uart_SetNumStopBits(hUartDevice, ADI_UART_ONE_STOPBIT);
    adi_uart_SetWordLen(hUartDevice, ADI_UART_WORDLEN_8BITS);

    adi_int_InstallHandler(INTR_UART0_STAT, Uart0Interrupt, NULL, true);

    void UartWrite(uint8_t* pBuf, uint32_t len)
    /* write data to the UART device using a blocking write */
    adi_uart_Write(hUartDevice, pBuf, len);

    int main(int argc, char *argv[])
    ADI_UART_RESULT eResult;

    * Initialize managed drivers and/or services that have been added to
    * the project.
    * @return zero on success

    /* Begin adding your custom code here */
    if(adi_pwr_Init(0, CLKIN) != ADI_PWR_SUCCESS)
    printf("Failed to initialize power service \n");
    return 0;


    sprintf((char*)uartTxBuf, "Hello there!!!..%d\n", count++);
    UartWrite(uartTxBuf, strlen(uartTxBuf));

    if(bUartRxFlag == true)
    UartWrite(uartRxBuf, strlen(uartRxBuf));
    bUartRxFlag = false;

    return 0;