Post Go back to editing

simple example on using UART interrupt to receive buffer from serial

Thread Summary

The user is trying to read data from UART in interrupt mode on a BF707 board but only receives the last character sent from the terminal. The final answer clarifies that the user needs to process each received byte individually and suggests referring to the FAQ on passing groups of characters via UART. The accompanying answer mentions using `adi_uart_IsRxBufferAvailable` in a loop to poll for incoming bytes, but this approach still results in printf writing to the serial output instead of the console.
AI Generated Content
Category: Software
Product Number: ADSP-BF592

Hi,

i would appreciate help in writing a simple test code to read data from UART in interrupt mode.

I am a newbe here.

I started with CharECHO_UART example and i was able to connect a terminal emulator (using a USB-DB9 cable). Then using Tera Term i sent a file

to my board and in DMA mode i was able to read all bytes i received.

Then i try something like:

static ADI_UART_HANDLE hDevice;

static void UARTCallback(void* pHandle, uint32_t u32Arg, void* pArg) {


printf("UART CALLBACK!!!!\n");
ADI_UART_HANDLE pDevice = (ADI_UART_HANDLE)pHandle;
ADI_UART_EVENT event = (ADI_UART_EVENT)u32Arg;
uint16_t *data = (uint16_t*)pArg;

printf("complete buffer:%s\n", ReceiveBuffer);

/*

here's the problem: my ReceiveBuffer contains only the last char sent from Termina Emulator

*/

}

int32_t main(void) {

// open UART in bidirectional interrupt mode mode

adi_uart_Open(UART_DEVICE_NUM, ADI_UART_DIR_BIDIRECTION, gUARTMemory_interrupt, ADI_UART_BIDIR_INT_MEMORY_SIZE, &hDevice);

adi_uart_SetBaudRate(hDevice, 115200u);

adi_uart_SetConfiguration(hDevice, ADI_UART_NO_PARITY, ADI_UART_ONE_STOPBIT, ADI_UART_WORDLEN_8BITS);

adi_uart_RegisterCallback(hDevice, UARTCallback, (void*)0);

adi_uart_SubmitRxBuffer(hDevice, ReceiveBuffer, 2);

adi_uart_EnableRx(hDevice, true);

while (true){

// do nothing

}

}

The problem is i only get the last character sent from terminal. I need to catch all chars sent from terminal

Each message sent from terminal may have different length so i need to process each received byte individually

I searched a lot and was not able to find a basic example that help me to build a simple program that read from UART in interrupt mode

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.