I'm working using atmel studio 7.0, the code which i'm using is USB Communication Device Class (CDC) for ATSAMD21. My application is to read the command from the host to the device and perform the operation suggested by the host and send acknowledgement back to the host from device.
Java GUI we are writing into MCU USB,we will receive data into MCU using udi_cdc_read_buf() call and received data we are sending back to the JAVA host as a acknowledgement using udi_cdc_write_buf() .
Device Waiting for second Command from host for sending response for first Command.
- Here host is sending data by bulk transfer and device is doing transfer by interrupt transfer.
- Device Waiting for second Command from host for sending response for first Command.
1st Command from host---->No acknowledgement received from device to host
2nd Command from host---->Host received acknowledgement for 1st Command .
3rd Command from host----->Host received acknowledgement 2nd Command.
Reading the data:
while (true) {
if(data_ready)
{
data_size=udi_cdc_multi_get_nb_received_data((uint8_t) port1);
udi_cdc_read_buf(rec_buffer,data_size);
}
->Here i set a flag if data is available it read the data.
Write back the data:
int write_data(uint8_t *msg){
uint8_t buffer[4]="3434";
udi_cdc_write_buf(buffer,4);
return (SUCCESS);
}
- I debugged DMA and all data transfer steps nothing is wrong in the transfer and reception. It wait for a new data to come. If i send data using serial port this error is not happening.
How this is happening in USB Communication? Is there any particular reason for happening like this.Any help will be appreciated.