Problem with DT_HID (maybe!)


Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Jul 2009
    Posts
    15

    Default Problem with DT_HID (maybe!)

    Hi all,

    Im having a little trouble using Darrel Taylors USB DT_HID "framework".

    Apologies for the long winded post, but I want to give as much information as possible as opposed to the classic "My code doesn't work, HELP!" ones you often see.

    Everything enumerates OK and my device transmits data correctly but receiving data is a different story. I have defned a set of 'messages' to allow simple communication between host and device. The messages take the form of two bytes - ID and data. Depending on what ID is received the approriate action is taken, e.g. Device receives Message ID "F", which indicates it should repsond by sending its firmware version string. In order to make sure errors are handled and reported if the device does not recognise the command it receives it responds by sending Message ID "u" and data = the message ID it does not recognise. The host software then alerts the user that an unknown command was sent to the devce.

    My problem is that any command I send results in the device responding with a "u" and what initially seemed to be a nonsense byte. It also seemed that this byte remained constant no matter what unrecognised command I sent e.g. I send 0x02 0x00 and I get the response 0x75 0x43 (equivalent to "u" "+"), then I send 0x03 0x00 and I still get 0x75 0x43 returned.

    However I later realised that if I reset my device the next time it responds the unknown command is set to whatever the last unknown command I sent was. This may sound confusing so I will illustrate:

    Code:
     
     
    Device reprogrammed here...
     
    Host sends:     Device Responds:
    ============================
    0x02 0x00       0x75 0x43
    0x02 0x00       0x75 0x43
    0x03 0x00       0x75 0x43
    0x03 0x00       0x75 0x43
     
    Device reset here.....
     
    0x02 0x00       0x75 0x03
    0x02 0x00       0x75 0x03
    0x03 0x00       0x75 0x03
    0x03 0x00       0x75 0x03
    0x04 0x00       0x75 0x03
     
    Device reset again...
     
    0x03 0x00       0x75 0x04
    0x70 0x00       0x75 0x04   <-- 0x70 is a valid command but is not being recognised
    etc.
    So as far as I can reason there are two possible problems - the Firmware on the device is somehow storing the unknown command but only recalling it when the device is reset and then freezing the buffer again until another reset - seems very unlikely since I do not believe the USB module uses non-volatile memory, unless toggling !MCLR is not actually resetting the USB memory?

    Or the device is working fine but the host software is failing to update its OUT buffer when I wish it to and is instead repeating the previous send until the device is reset whereupon it finally updates the buffer with the most recent requested bytes. This seems like the most intuitive simply because I would expect resetting the device would destroy any past knowledge of bytes I have sent. However I have used a USB analyser program and it suggests I am sending what I am trying to send and receiving what I think I am receiving. Assuming this is monitoring at the lowest level then it must be the device that is incorrect.

    Basically I am at hair pulling frustration levels! If anyone knows exactly whats wrong then great! If not then any suggestions on what I could try would be welcome.

    Heres a description of my setup:

    PBP 2.60 developing in MPLAB. PIC18F2550, 4MHz Clock.
    DT_HID260.pbp - modified slightly for my needs - changed the Usage Page information so that my software can pick up Windows Messages from it more easily
    VB6.0 host software.

    Attached is my firmware code. If you need me to I can attach some of the vb 6 code but its an activex which makes it a little complicated - let me know if it would be helpful.

    Thanks in advance!
    Attached Files Attached Files

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts