• AVR Freaks

Hot!Harmony v3 configuration for USB HID Device

Author
tedfalasco
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/12/16 14:35:54
  • Location: 0
  • Status: offline
2020/04/08 06:52:25 (permalink)
0

Harmony v3 configuration for USB HID Device

Hello,
 
I am trying to create a Harmony v3 project to get the PIC32MZ2048EFM144 on the Curiosity 2.0 evaluation kit to enumerate as an HID USB device when I connect the "Target USB" connector to my computer.
Here's what I have tried so far...
 
I started with a copy of the demo app located here:
C:\microchip\harmony\v3\usb\apps\device\hid_basic\firmware\pic32mz_ef_sk.X.
 
The demo app is for the PIC32MZ2048EFH144, so I changed the configuration to target the device on the Curiosity 2.0 board, specifically the PIC32MZ2048EFM144.
 
Next, I opened MHC and made the following changes:
  1. Remove the PIC32MZ EF Starter Kit BSP, since this is not the kit I am using.
  2. Edit Pin Settings to remove the predefined LED (RH0) and SWITCH (RB12) because they do not line up with an LED or a switch on the Curiosity 2.0 board.
  3. Edit Pin Settings to define LED as RJ7. Configured as GPIO, Out, High, Open drain.
  4. Edit Pin Settings to define SWITCH as RJ4. Configured as GPIO, In, Change notification, Pullup.
I made no further changes in MHC at this point, leaving the USB HS driver, USB device layer, HUD function driver, Core timer, and Time modules as provided in the sample, saved the configuration, then generated the code.
 
So far so good. A clean-and-build produced errors because functions LED_Off() and LED_On() were not defined, and neither was the constant SWITCH_STATE_PRESSED. Not a problem. I just defined these as LED_Set(), LED_Clear(), and 0x00, respectively.
Now a clean-and-build produces no errors or warnings, so I loaded this code into the PIC32 on board using the "Make and Program" button.
 
I unplugged the USB cable from the "DEBUG USB" port on the Curiosity 2.0 board and plugged it into the "TARGET USB" port. Here's where I run into problems. On Windows 10, the device does not enumerate and in fact, the Device Manager doesn't show any changes when the board is plugged in or unplugged. However, while the board is plugged in, Windows repeatedly makes the sound it makes when a USB device is plugged in and a "USB Device not recognized" message occasionally pops up.
 
For diagnostic purposes, I also plugged the board into a Linux machine and it would not enumerate there either. I looked at the syslog and found these entries, which coincide with the Curiosity 2.0 board being plugged in:

Apr 8 08:24:41 ted-Inspiron-620 kernel: [60730.268493] usb 2-1.3.1: new high-speed USB device number 42 using ehci-pci
Apr 8 08:24:42 ted-Inspiron-620 kernel: [60730.440486] usb 2-1.3.1: new high-speed USB device number 43 using ehci-pci
Apr 8 08:24:42 ted-Inspiron-620 kernel: [60730.532777] usb 2-1.3-port1: attempt power cycle
Apr 8 08:24:42 ted-Inspiron-620 kernel: [60731.136530] usb 2-1.3.1: new full-speed USB device number 44 using ehci-pci
Apr 8 08:24:43 ted-Inspiron-620 kernel: [60731.552516] usb 2-1.3.1: device not accepting address 44, error -32
Apr 8 08:24:43 ted-Inspiron-620 kernel: [60731.632502] usb 2-1.3.1: new high-speed USB device number 45 using ehci-pci
Apr 8 08:24:43 ted-Inspiron-620 kernel: [60732.052513] usb 2-1.3.1: device not accepting address 45, error -71
Apr 8 08:24:43 ted-Inspiron-620 kernel: [60732.052914] usb 2-1.3-port1: unable to enumerate USB device
 
The LED on the Curiosity 2.0 board does not illuminate and the switch has no discernible effect.
 
It occurred to me that this might be a problem with power. I check the schematic and it shows the 5V from the TARGET USB connector feeding into the 3.3V regulator that powers the PIC32. That should be fine, but it's easy enough to provide another power source. The 5V from the DEBUG USB becomes PKOB_P5V0, which also feeds into the 3.3V regulator that powers the PIC32. I plugged in a separate USB cable to the DEBUG USB connector and connected it to a 2A, 5V charging block, which should provide all the power necessary for the PIC32. I then reconnected the TARGET USB to my computers and came up with the same result.
 
Bored yet? There's more...
 
I saw in the code that there are debug statements scattered throughout, so I configured the project to write the debug statements to UART6, which should write to the virtual com port created when DEBUG USB is connected to the computer. Here, exactly, are the steps I took to do that:
  1. Using MHC, add Harmony->System Services->Debug.
  2. On the Debug module, right-click the SYS_CONSOLE dependency and select Satisfiers->CONSOLE.
  3. On the Console module, right-click the UART dependency and select Satisfiers->UART6.
  4. Configure UART6 for 115200, 8N1.
  5. Edit Pin Table to select pin 79 for U6TX.
  6. Save configuration and generate code.
Now a clean-and-build generates a number of errors around implicit declarations and undeclared symbols from the debug library. These were all resolved by adding #include "system/debug/sys_debug.h" to usb_device.c. Now a clean-and-build does not generate any errors or warnings.
I programmed the code into the PIC32 as usual.

I launched TeraTerm and configured it for the virtual com port (COM13 in my case), also set for 115200, 8N1 like the UART6 module in MHC.
 
Here I observed debug output, but it appeared to be the gobbledygook you typically get when the baud rate doesn't match between serial ports. I faffed about for a while troubleshooting this. I switched UART and serial port settings, and switched them back. I verified UART6 does indeed write to TeraTerm correctly on a clean project. I switched between blocking and non-blocking UART6 writes. I configured the unused UART6 receive pin, just in case. Etc., etc., ad nauseum. In the end, I could not get the debug output to write in clear text in this project.
 
Here I realized I am probably missing something more basic and I am getting further and further away from my goal of getting the HID USB demo project to work.
 
Has anyone had any luck getting the TARGET USB on the Curiosity 2.0 to enumerate as a HID device?
Or, can anyone offer troubleshooting suggestions or other advice for me to try?
 
Thank you,
-Ted
#1

3 Replies Related Threads

    BillP
    Super Member
    • Total Posts : 405
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: Harmony v3 configuration for USB HID Device 2020/04/09 08:05:02 (permalink)
    0
    I am confused about your post.  It sounds as if you got the UART6 to work using the DEBUG USB port on the Curiosity Dev 2 board, then you plugged the cable into the TARGET USB port.  Right?  Not good.  The two USB ports are different.  You need to configure the TARGET USB port using the configuration options from the Project Graph icon, then add code to control the I/O to that USB device.
    I have not tried the USB HID but I think it is similar to the CDC function.  I have a working 2-port CDC device connected to the TARGET USB port using Hv3 and the 2.0 board.
     
    #2
    tedfalasco
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2019/12/16 14:35:54
    • Location: 0
    • Status: offline
    Re: Harmony v3 configuration for USB HID Device 2020/04/09 08:31:12 (permalink)
    0
    Hi BillP,
     
    Thanks for your response.
     
    I am using the TARGET USB port as a USB port in my application, which, when plugged in to a PC, would enumerate as an HID device.  I am also--and separately--using the DEBUG USB port to print debug messages to a serial console so that I can debug my application.  
     
    As it turns out, the "something more basic" that I suspected I was missing was that the Curiosity 2.0 board has a 12 MHz oscillator and my clock configuration incorrectly had the primary oscillator configured as a 24 MHz oscillator.  I was clued in to the oscillator mis-configuration because although my UART6 and my serial console were both configured for 115200 8N1, there appeared to be a baud rate mismatch.  
     
    Rookie mistake on my part, but we're off and running with HID communication and debug messages both working correctly now.
     
    Thanks,
    -Ted
    #3
    BillP
    Super Member
    • Total Posts : 405
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: Harmony v3 configuration for USB HID Device 2020/04/09 16:54:38 (permalink)
    0
    Not a rookie mistake.  When I ran across this last year, I submitted a support ticket, asked for a new board (of course the replacement did the same thing), and posted on this forum.  Someone finally saw the post and reveled that the USB clock on the 2.0 board had changed (but it was not mentioned in the documentation).  I posted the solution as a warning to others.  Sorry you missed it.
    Bill
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5