Simplified Microchip PIC USB demos (C18/XC8 MLA)

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Mon Jul 27, 2015 11:22 am

Max wrote:I was able to switch OFF/ON LED. As I click on Switch ON, then Input HEX reads: 1 b1, and 1 b0 for OFF.

Ok, the first byte "1" is for the amount of useful bytes in the transmission.
"xb1" is the "acknowledge" of the instruction "x41" because the response is created by adding 0x80 (setting the msb) to the request.
((( "x41" is for LED_4 ON and "x40" is for LED_4 OFF )))

Max wrote:But when I click Device or Version, it reads: 1 ff, for both the options. And it doesn't display the info in the software. So something might be wrong in passing input from the software to the circuit, I guess?

0xff means ERROR (unknown command)
I guess this is because I changed the command IDs. In the early versions the Device was x10 and the vesion x11.
Now they are 0x0f for the device and 0x0e for the version. There is a hint in post #4.

You can easily check this if you use the "HEX OUT 1" and "HEX OUT 2" buttons on the first tab which are preset with these comands.
<edit>Sorry, of course you have to edit them to 0x10 and 0x11 then ;-)</edit>

Max wrote:BTW, which USB driver did you use for implementing your software? Did use Windows' built-in HID drivers to communicate with device?

I use Alan Ott's HID-API which can be used for Win, Linux and MAC OS. It uses the Windows build-in HID driver ...
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby deiv23 » Fri Aug 07, 2015 12:37 pm

Hi,
first of all thank you very much for the demos.
I downloaded the r2 hid demo, built the project succesfully in mplab. When I plug the usb cable the computer detects the new hid device.
To test it I made a python program that sends data from the computer to the pic (in my case i just need this direction of the data). So I built a 65 bytes buffer beginning with 0x00 in the first byte, and then I sent it.
I put a breakpoint in method APP_usbOUT, the execution stopped in this breakpoint when i send the data from the computer. The problem is after executing:
Code: Select all
      USBOutHandle = HIDRxPacket(HID_EP,(uint8_t*)&ReceivedDataBuffer,64);

the ReceivedDataBuffer is empty.

Could you give me some clues on why it isn't working fine? I have been searching in the code to find out the reason but I couldn't find. (I'm just a beginner programing pics)

Thank you.
deiv23
 
Posts: 12
Joined: Fri Aug 07, 2015 12:21 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Fri Aug 07, 2015 12:47 pm

deiv23 wrote:The problem is after executing:
Code: Select all
USBOutHandle = HIDRxPacket(HID_EP,(uint8_t*)&ReceivedDataBuffer,64);

in
Code: Select all
void APP_usbOUT(void) {

    APP_cmd();

    //Re-arm the OUT endpoint for the next packet
    USBOutHandle = HIDRxPacket(HID_EP,(uint8_t*)&ReceivedDataBuffer,64);
}
the ReceivedDataBuffer is empty.

This function is the setup for a new "future" receiving after you precessed the current one.
So it may be normal that it clears the receiver buffer ?
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby deiv23 » Fri Aug 07, 2015 1:07 pm

ok,
but into the APP_cmd() method it should have a value right?
it doesn't
deiv23
 
Posts: 12
Joined: Fri Aug 07, 2015 12:21 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Fri Aug 07, 2015 1:19 pm

Are you using windows?

You could try to check the USB with a software sniffer like:
http://www.hhdsoftware.com/Downloads/usb-monitor

or try my Qt HID-Demo. There is also a executable found here
http://www.hs-ulm.de/nocache/wir/Person ... tProjekte/
YOU NEED THE DLLs AS WELL. Simply copy the HID-Demo_...exe into the folder with the dlls
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby deiv23 » Mon Aug 10, 2015 11:11 am

Yes, I'm using windows.

Maybe I found what is wrong. I was adding the path to the library in the compiler's include directories. I mean, I was referring to the mla\v2014_07_22\framework into c:\microchip, the library itself. Now I'm referring to the mla that is one level up from the project directory.
The problem is now it doesn't build, it asks me for the file:
(141) can't open include file "usb/src/usb_device_local.h": No such file or directory

As I told you I'm a beginner, just installed the 2014 mla in c:\microchip, now I have two mlas, that one and the 2015 version. I have to tell mplab which version it has to use somewhere?
deiv23
 
Posts: 12
Joined: Fri Aug 07, 2015 12:21 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Mon Aug 10, 2015 11:28 am

The zip that you downloaded should contain all necessary files.
If the project builds ok, it should be fine.
You'd better try to check the USB communication with your host software as I told you
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby deiv23 » Mon Aug 10, 2015 11:35 am

I'll check it now.
Another question, where can I find the dlls for your Qt-hid demo? I downloaded a zip with all the source files, but I couldn't find the dlls.
deiv23
 
Posts: 12
Joined: Fri Aug 07, 2015 12:21 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby deiv23 » Mon Aug 10, 2015 12:18 pm

This is the rawdata I obtain. The write packet is the one I'm sending, just setted the first bytes to 12, ff, 00, ff....
Attachments
capturasniffer.png
capturasniffer.png (94.07 KiB) Viewed 8766 times
deiv23
 
Posts: 12
Joined: Fri Aug 07, 2015 12:21 pm

Re: Simplified Microchip PIC USB demos (C18/XC8 MLA)

Postby vloki » Mon Aug 10, 2015 12:26 pm

deiv23 wrote:I'll check it now.
Another question, where can I find the dlls for your Qt-hid demo? I downloaded a zip with all the source files, but I couldn't find the dlls.


The linked page some posts above does not provide any source files. Only the executable and the dlls ...
Last edited by vloki on Mon Aug 10, 2015 12:48 pm, edited 1 time in total.
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

PreviousNext

Return to USB

Who is online

Users browsing this forum: No registered users and 8 guests

cron