Author Topic: USB IN Transaction not Send!!!!  (Read 16642 times)

eng.Buffon

  • Member
  • ***
  • Posts: 23
USB IN Transaction not Send!!!!
« on: February 24, 2012, 12:06:13 pm »
hi Mr.Jan

i am developing an HID Device using PIC18f4550 and i used the usb framework of the Microchip but in some modification..

The Pic is enumerated successfully and i send information from the PC and the PIC read it successfully using this function :

Code: [Select]
// Read up to len bytes from HID output buffer.  Actual number of bytes put into
// buffer is returned.  If there are fewer than len bytes, then only the available
// bytes will be returned.  Any bytes in the buffer beyond len will be discarded.
byte HIDRxReport(byte *buffer, byte len)
{
    hidRxLen = 0;
 
    // If the SIE doesn't own the output buffer descriptor, then it is safe to
    // pull data from it.
    if(!(ep1Bo.Stat & UOWN))
    {
        // See if the host sent fewer bytes that we asked for.
        if(len > ep1Bo.Cnt)
            len = ep1Bo.Cnt;
       
        // Copy data from dual-ram buffer to user's buffer

        for(hidRxLen = 0; hidRxLen < len; hidRxLen++)
        {
            buffer[hidRxLen] = HIDRxBuffer[hidRxLen];
        }

        // Reset the HID output buffer descriptor so the host
        // can send more data.
        ep1Bo.Cnt = sizeof(HIDRxBuffer);
        if(ep1Bo.Stat & DTS)
            ep1Bo.Stat = UOWN | DTSEN;
        else
            ep1Bo.Stat = UOWN | DTS | DTSEN;
    }

    return hidRxLen;
   
}

that return number of bytes got from the host and i could read the buffer successfully

the problem is when using Write function to write some information to the pc i used this function:
Code: [Select]
byte HIDTxReport(byte *buffer, byte len)
{
    byte i;
    // If the CPU still owns the SIE, then don't try to send anything.
    if (ep1Bi.Stat & UOWN)
        return 0;

    // Truncate requests that are too large.  TBD: send
    if(len > HID_INPUT_REPORT_BYTES)
        len = HID_INPUT_REPORT_BYTES;

   // Copy data from user's buffer to dual-ram buffer
    for (i = 0; i < len; i++)
        HIDTxBuffer[i] = buffer[i];

    // Toggle the data bit and give control to the SIE
    ep1Bi.Cnt = len;
    if(ep1Bi.Stat & DTS)
        ep1Bi.Stat = UOWN | DTSEN;
    else
        ep1Bi.Stat = UOWN | DTS | DTSEN;

    return len;
}

and it return the number of bytes supposed to be written but when check the buffer there is nothing

when i used USB Analyzer

i discovered that it doesn't sense that there is IN transaction but it sense OUT transaction successfully

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB IN Transaction not Send!!!!
« Reply #1 on: February 24, 2012, 02:04:21 pm »
Use breakpoints, watch variables, or whatever other debugging tools you have to find out if the buffer contains the data you want to send.

Jan

eng.Buffon

  • Member
  • ***
  • Posts: 23
Re: USB IN Transaction not Send!!!!
« Reply #2 on: February 24, 2012, 02:24:50 pm »
which buffer you mean the USB module buffer or RAM-Buffer

eng.Buffon

  • Member
  • ***
  • Posts: 23
Re: USB IN Transaction not Send!!!!
« Reply #3 on: February 24, 2012, 02:32:10 pm »
i tried debug HIDTxBuffer an i see that the buffer contain data correctly

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB IN Transaction not Send!!!!
« Reply #4 on: February 24, 2012, 02:57:20 pm »
Then continue to follow it through the firmware.

Also be aware that the HID driver will ignore any reports that don't match a size defined in the report descriptor.

If using the default report ID of zero, the report ID doesn't transmit on the bus.

A hardware analyzer will show all data on the bus. A software analyzer looks at a higher level and might not show everything.

Jan

eng.Buffon

  • Member
  • ***
  • Posts: 23
Re: USB IN Transaction not Send!!!!
« Reply #5 on: February 24, 2012, 04:31:01 pm »
Thanks Mr Jan

The problem was that there were addressing conflict in the RAM some variable with the same address..

So when i debug i found them and change them and it works Fine

Thank you very much for your help