Right, as promised here are the files for the USB HID joystick. The source code only makes sense for my schematic so adjust as you see fit. As always, if you use this code, please do at least give credit where credit is due. It's been a long battle trying to understand both USB on the PIC32MZ and understanding how USB works in general.
Schematic
Here's a low quality render to give some approximation of what the board looks like in real life
OK, enough of that, Here's the source code
And here are the KiCad files if you need them.


5 comments
Stephen Gordon
Looks nice! Are you using stencils to put your solder on the board? There is not much possibility chance of rework with leadless packages!
Aidan Author
Hi there Stephen, thanks for stopping by. You may be horrified to know that I tin all the pads with my old soldering iron and then use my cheap rework station’s air gun to solder it down :) I’ve been doing it for a few years so I’ve gotten pretty good at it!
Stephen Gordon
Nice... flux is your friend :) If you're interested in a cheap way to start doing reflow there was a PIC32MZ-based reflow controller in Silicon Chip magazine (siliconchip.com.au) a couple of years ago. It just uses PID control to switch the mains power supply of a cheap toaster oven and it's great for boards with a lot of components as those take ages to solder by hand. However, it is difficult to control the amount of solder paste applied with a syringe so I still solder anything with <0.5mm pitch and >16 pins by hand. I don't currently have a way of doing these leadless packages, but then again I don't have an air gun so I will avoid using them for the moment.
Sorry about the long delay, I did read your reply straight away but was busy and forgot to come back. Hope you're enjoying using the joystick!
Jeff
Hi Aidan. I'm amazed, you have done a so incredible job, sharing your experience, your knowledge, time and effort.
I'm new to embedded programming area, been messing with PIC16 for sometime and now just got my hands on a PIC32MX and since then, I've been trying to do things using Harmony 3 by learning from Microchip's examples.
Unfortunately, just like you pointed out, many things are not beginner friendly and I have been struggling to do a project which involves having multiple usb audio interfaces in a single chip. I successfully rewrote their usb microphone example using my PIC32, but it has only one audio interface and when I add a second one using Harmony MCC, it doesn't work anymore. The worst reason is my lack of knowledge, not only about MCUs but also USB development I guess.
Anyway, I am considering to learn how to program a chip from scratch just like you did, instead of struggle using their tool.
I mean, it's not hard to use Harmony at all, but it hides a lot of things, which can be very problematic for a beginner when troubleshooting errors, since it will require reverse engineering their code while learning.
I just wanna say huge thank you for sharing this with us.
Jeff.
Aidan Author
Hi Jeff,
I'm not good at replies seeing how late this is, but thanks for that. I am glad to hear my code is still being useful to someone :)
Comments are hosted by Disqus, which loads only when you ask for it.