Great work... I think we can also make an issue containing the above.
http://code.google.com/p/jallib/issues/list

When I do my testing of other USB issues, I can test this one as well.
I plan to test all USB samples.

Matt.

On Feb 16, 9:21 pm, "ivan.jal33" <[email protected]> wrote:
> The problem is that no code can trust the data in any buffer
> discriptor without the buffer descriptor's uown bit being cleared (the
> only trusted part is the uown bit in the status register). This is
> from the PIC's datasheet. I use the 18F14K50, but there are many pics
> with similar BD structures and uown bits.
>
> For transmissions TO the host, the status uown bits are tested and
> work. For receptions FROM the host, the status uown bits are not
> checked first. The result is an intermittent extra data received.
>
> The fix is to read the uown status bit in the BD to see if it is
> cleared, before reading the address and byte-count from the BD, then
> call the usb_ep_data_out_callback to retrieve the data from the
> endpoint only when cleared.
>
> I made a fix that is not elegant, but is simple to understand and
> works to repair the problem. This actually works in my real hardware.
> The lines I added -- *
>
> broken snipet:
>
>     if defined(usb_ep_data_out_callback) == true then
>          var byte idx = end_point * 8
>
>          var word addr
>          var byte bcnt
>          var byte bt_addr[2] at addr
>
>          bt_addr[0] = usb_bd_array[ idx + 2 ]
>          bt_addr[1] = usb_bd_array[ idx + 3 ]
>          bcnt = usb_bd_array[ idx + 1 ]
>
>          usb_ep_data_out_callback( end_point, addr, bcnt )
>
>     else
>          usb_prime_epx_out( end_point, 0x08 )
>     end if
>
> FIXED SNIPPET:
>
> if defined(usb_ep_data_out_callback) == true then
>      var byte idx = end_point * 8
>
>      var byte _statBD = usb_bd_array[idx]    --
> *
>      var bit statBD at _statBD : 7                 -- *
>      if  statBD == 0 then                             -- *
>
>           var word addr
>           var byte bcnt
>           var byte bt_addr[2] at addr
>
>           bt_addr[0] = usb_bd_array[ idx + 2 ]
>           bt_addr[1] = usb_bd_array[ idx + 3 ]
>           bcnt = usb_bd_array[ idx + 1 ]
>
>           usb_ep_data_out_callback( end_point, addr, bcnt )
>
>      end if                                                -- *
>
> else
>      usb_prime_epx_out( end_point, 0x08 )
>
> end if
>
> Special thanks to Matt for reviewing.
>
> ivan.jal33

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to