This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB CDC failing to read after reading first byte ( ATSAML21J18B)

Application:

Receive data from java (GUI) application,and send it back to the GUI. Using "USB Device CDC Example" for ATSAML21J18B .

Issue:

The problem i'm facing is ,from the java application if a string is sent, receiving only one byte.

Code Snippet:

I'm the code for "USB Device CDC Example".

Receiver Code:

< static uint8_t rx_data;

void uart_rx_notify(uint8_t port)
{ UNUSED(port); if (!tx_callback_flag) { /* Transmit first data */ ui_com_rx_start(); usart_enable_callback(&usart_module_edbg, USART_CALLBACK_BUFFER_TRANSMITTED); tx_data = udi_cdc_getc(); udi_cdc_putc(tx_data); usart_write_buffer_job(&usart_module_edbg, &tx_data, 1); }
}/> -Here i'm doing in such a way that if data is received to the receiver buffer send it back to the GUI. If GUI is sending 10 bytes i'm only able to receive 1 byte.

Things i've tried:

From this link i got some solution and i tried to implement this by adding count to my read buffer from this link www.microchip.com/forums....

I changed my code as follows:

< #define USB_DATA_BUFFER_COUNT 10

static uint8_t tx_data[USB_DATA_BUFFER_COUNT];
static uint8_t rx_data[USB_DATA_BUFFER_COUNT];
static uint8_t rx_count=0;
static uint8_t tx_count=0;

void uart_rx_notify(uint8_t port)
{

UNUSED(port); if (!tx_callback_flag) { /* Transmit first data */

usart_enable_callback(&usart_module_edbg, USART_CALLBACK_BUFFER_TRANSMITTED);

tx_data[rx_count] = udi_cdc_getc(); rx_data[rx_count]=tx_data[rx_count]; tx_count=rx_count; rx_count++; if(rx_count>=USB_DATA_BUFFER_COUNT){ rx_count=0; } udi_cdc_putc(rx_data[tx_count]); usart_write_buffer_job(&usart_module_edbg, tx_data, 1);

}
}>
*Here in this case if thr GUI send 10 byes i'm receiving 1 byte correctly rest of 9 bytes are showing junk data.

*Please help me to solve this issue.

Any help will be appreciated .

Thanks in Advance