Hey you all,
I have a function that builds a table (stored on heap) with 256 elementes received on my Usb connection and the program takes to long to generates this table that my USB connection brokes (i hear the Windows sound when you unplug a device). I call this function after HID_Device_USBTask() and USB_USBTask() functions inside the while loop but as you can imagine, it didn´t work well.
This situation gets worse when i call the function to compute the 256 elements of data.
That's what i do: i receive a block of 8 bytes of data and append each block to my big ass table! My code works with a short tables like 16 bytes or so, but with a big one like 256 bytes it goes to hell!
It seems that the USB conection it ran a time-out or something.
There is my pseudo-code:
uint8_t *p_data_to_save = NULL;
uint8_t *p_data_to_host = NULL;
p_data_from_host = (uint8_t*)calloc(8, sizeof(uint8_t));
p_data_to_save = (uint8_t*)calloc(256, sizeof(uint8_t));
if (new_bytes_recived == true )
// Append 8 bytes received to my 256 bytes table
if(indx_data < 255)
for(int i=0; i<8; i++)
p_data_to_save[indx_data] = p_data_from_host[i];
new_bytes_recived = false;
if(table_completed == true)
// Process the 256 bytes of data
(...) // other smal if-cases
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
const uint8_t ReportID,
const uint8_t ReportType,
const void* ReportData,
const uint16_t ReportSize)
unsigned int i;
uint8_t* Data = (uint8_t*)ReportData;
new_bytes_recived = true;
Any solution to this?
Thank you all
PS: I'm using an Atmega16u2.