avr - LUFA USB Connection Timeout -


someone pro in lufa framework , avr microcontrollers?

i have function builds table (stored on heap memory) 256 elementes received on usb connection , program takes long generates table usb connection brokes (i hear windows sound when unplug device). call function after hid_device_usbtask() , usb_usbtask() functions inside while loop can imagine, didn´t work well.

this situation gets worse when call function compute 256 elements of data.

that's do: receive block of 8 bytes of data , append each block big ass table! code works short tables 16 bytes or so, big 1 256 bytes goes hell!

it seems usb conection ran time-out or something.

there pseudo-code:

uint8_t *p_data_to_save = null; uint8_t *p_data_to_host = null;  int main(void) {     p_data_from_host = (uint8_t*)calloc(8, sizeof(uint8_t));     p_data_to_save = (uint8_t*)calloc(256, sizeof(uint8_t));      setuphardware();     leds_setallleds(ledmask_usb_notready);     globalinterruptenable();      (;;)     {         hid_device_usbtask(&generic_hid_interface);         usb_usbtask();          if (new_bytes_recived == true )         {              // append 8 bytes received 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];                   indx_data++;                 }             }              new_bytes_recived = false;          }           if(table_completed == true)          {               // process 256 bytes of data              process_table();           }            (...)  // other smal if-cases     }     free(p_data_from_host);     p_data_to_host=null;     free(p_data_to_save);     p_data_to_save=null; } 

on callback_hid_device_processhidreport():

 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;   (i=0;i<8;i++)   {      p_data_from_host[i]=data[i];   }     new_bytes_recived = true; } 

any solution this?

thank all

ps: i'm using atmega16u2.

the atmega16u2 has 512 bytes of ram. didn't show definition of table think it's safe assume table takes entire ram. it's bad linker didn't give warning this. you'll have better microcontroller (like atmega32u4) or make table smaller.

keep in mind local , global variables stored in ram default, can't use of ram table.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -