Close
0%
0%

PIC16 & PIC18 USB Stack

A easy to use USB stack for PIC16/PIC18

Similar projects worth following
Back in early 2017 I decided I wanted to know how to use the USB peripheral in PIC microcontrollers. I looked through microchip's MLA USB examples and found the API was easy to use, but the underlying code was not easy to follow (lots of files to keep track of). So I decided it would be an interesting exercise to write my own stack... I stumbled across Voja Antonic's Supercon II badge project and thought it was really cool. I particularly liked how the badge could be plugged into a computer and the computer would see it as a USB drive, and you could program it by dragging and dropping your intel hex file onto it. The EXPRESS dev boards from microchip use similar code. I was so inspired I set my first major goal to make a similar MSD bootloader. Little did I know how much was involved lol... I firstly made a HID stack with examples, followed by MSD and bootloader (see USB uC), then lastly CDC...

Enjoy this project?

Share

Discussions

larry wrote 07/21/2019 at 09:18 point

Very good project Johnny, works fine!

I parsed the source code. Have you some plans to conform to BARR-C:2018 firmware rules ?

I may help if you have.

BR

Larry

  Are you sure? yes | no

Johnny wrote 08/12/2019 at 03:37 point

Hey Larry, 

sorry I missed your comment. I hadn't made plans to conform to any coding standards. The stack was originally an exercise for myself, to learn about USB protocols and the PIC's USB peripheral. So I originally didn't intend to release it publicly, and especially not as an alternative to Microchip's stack or others.

I've had several people ask about how I got MSD to work on the PIC16F145X (because microchip's MLA doesn't support it) and if I could share the code. So I decided to release the stack with examples, why keep it all to myself?

I'm definitely not a professional programmer, I program as part of my day job, and the stuff I make seems to work lol, but I'm not overly confident in my skills as a programmer, so I'd advise others to use the "tried and tested" stacks for professional work, and mess around with mine if they're curious.

 If you want to modify the code and get it to conform to BARR-C:2018, please go for it and let me know how it goes. Could be a good foundation for a "professional" stack. I don't really have the time or need to do it myself.

  Are you sure? yes | no

larry wrote 08/12/2019 at 06:46 point

Hy Johnny,
I understand ;-) I use strong coding standards rules in my job, but I am more an hobbyist with  PIC microcontrollers.

MAL stack is so weird-written that I always wondered how it could work and most of the time, I had to deactivate all optimizations.

Anyway, coming to your implementation, I never had a so stable USB stack even with full compiler optimization ! I use mainly cdc to communicate for and back with my devices...

I started to make some changes (aesthetical) and trying to figure out how to best conform to a pro standard, because from what I saw, your stack is a very good candidate for it.

I'll keep you inform on what is done.

Best regards

Larry

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates