USB library questions

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
rocketbob
Registered User
Registered User
Posts: 51
Joined: Sun Apr 01, 2007 1:36 am
Location: Indiana USA

USB library questions

Post by rocketbob » Sat Mar 07, 2015 2:29 pm

Hi Gents,

Trying to get my head wrapped around the SF USB library. I would like to update an older project to use a USB bootloader on a PIC device that supports USB. Mainly I am looking at eliminating a max232 and having to use a USB to RS232 converter in my debugging, not necessarily to have a PC-connected device. How would I go about implementing a USB bootloader that interfaces with the PC as a VCP so that the Microcode Loader in the SF IDE "just works"?

Thanks,
Bob

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: USB library questions

Post by David Barker » Sat Mar 07, 2015 6:23 pm

I use a 18F14K50 on the Firewing boards

http://www.firewing.info/

which provides RS232 support over USB. Microcode loader would work fine with this setup. The complete source code can be found at the bottom of this page:

http://www.firewing.info/pmwiki.php?n=F ... Firewing08

It's written in Firewing but Gavin (bitfogav) did a Firewing to Swordfish conversion, which is attached. Schematic can be found here:

http://www.firewing.info/downloads/sche ... -pic18.pdf

If you do not use the code then it will at least give you some pointers. The advantage of having a separate 18F14K50 is that you can target any non-usb PIC device, like Firewing does.
Attachments
usbSwordfish.zip
(3.65 KiB) Downloaded 234 times

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: USB library questions

Post by Jerry Messina » Sat Mar 07, 2015 9:15 pm

For a single-chip solution the main problem I had when trying to implement a USB CDC/VCP bootloader was the size and complexity.

The USB CDC stack code ends up being about 4K bytes, and that's just to be able to echo chars. By the time you add in the code to actually read data and program a chip it ends up pretty darn big!

What I usually do in my USB-only devices is to implement a HID bootloader and just use the Microchip bootloader app to do the programming. You can use the HID bootloader and still use a CDC/VCP port for your SF application code. I do that all the time. Be warned - the HID bootloader code isn't exactly tiny... it comes in at just under 4K too (but at least that's the whole thing).

I've included both the SF pic code (SF HIDbootloader143) and the PC-side code/exe (Microchip HID Bootloader) in the SFUSBv143 libraries at http://www.sfcompiler.co.uk/wiki/pmwiki ... USBLibrary

To be honest, I still prefer the "serial port" method. I'd rather not be stuck with a dedicated PC-side app to do the downloading (and it's not VCP, so it won't work w/the Microcode Loader), but it's workable.

User avatar
rocketbob
Registered User
Registered User
Posts: 51
Joined: Sun Apr 01, 2007 1:36 am
Location: Indiana USA

Re: USB library questions

Post by rocketbob » Sun Mar 08, 2015 1:11 am

Great info. The size of the bootloader is a bit of a bummer but I am still going to try this approach. Thanks guys!

User avatar
rocketbob
Registered User
Registered User
Posts: 51
Joined: Sun Apr 01, 2007 1:36 am
Location: Indiana USA

Re: USB library questions

Post by rocketbob » Sun Mar 08, 2015 1:58 am

I believe another workable alternative to a USB bootloader is to wire an HC-06 bluetooth module in place of the max232, which should work fine with Microcode loader.

Post Reply