Robert Bailey

9S08JM60 USB issues with HID mode

Discussion created by Robert Bailey on Jan 21, 2009
Latest reply on Jan 29, 2009 by Oliver Gosling
I have been trying to implement HID mode communication with my project.  The PC side seems to be operating fine, but for some reason I am getting corrupted data coming out of the JM60.  It seems to happen when the PC and JM are trying to communicate at the same time.
In watching the USB comms using a sniffer program,  the data going to the JM is ok,  but some of the OUT data is showing up in the IN data.  Its not consistent.
The OUT data is going on on endpoint 0,  the IN data is on endpoint 1 (81)
Do I need another endpoint to separate the data properly?  Or do I just have an error in my JM60 code?
I did make a small change to hid_process() so the software would not have to wait.  It is shown below,  perhaps my logic is flawed.
I am attempting to send 64 bytes every 100 ms.  hid_process() is called in the main endless loop.
/***************************************************************************** * HID_process ****************************************************************************/void hid_process(hcc_u8 id)      ////  !!!!! modified for ONE IN Report{                                //  poll this function quickly                                //  this function will lockout further                                  //  sending until the prev. one is gone.static char tempcharHID;                                     if (usb_get_state() != USBST_CONFIGURED)  {    return;   }    tempcharHID =  usb_ep_is_busy(HID_IT_EP_NDX);  if(USB_BusySending == 1  &&  tempcharHID)    {    // if busy sending, exit    return;    }  else    {     USB_BusySending = 0;    }// if report is pending, send it. set busy flag      if(reports[id].used        && reports[id].pending            && reports[id].type==rpt_in)    {      usb_send(HID_IT_EP_NDX, (void *)0               , reports[id].buffer               , reports[id].size               , reports[id].size);//      while(usb_ep_is_busy(HID_IT_EP_NDX))//        ;      reports[id].pending=0;      USB_BusySending = 1;//      break;    }}