PIC32 porting, Microchip USB stack, demo?

piero74 wrote on Tuesday, March 23, 2010:


i need a freeRTOS demo for pic32, that includes the microchip USB stack.
I’m interested to understand how i can integrate stsck in my application, using USB stack irq (i need an fully event driven system)

I need examples for both modes, DEVICE and HOST - i means virtual com device ans mass storage host

Thank in advance to all.


davedoors wrote on Tuesday, March 23, 2010:


piero74 wrote on Tuesday, March 23, 2010:

i know this documents, and i already integrated code inside freertos. But Microchip USB is not an easy code, and i will prefer to start from a ready-to-use example. Now i have only examples (from microchip) that works without FREERTOS.

My question is only if someonr in the forum already did some similar works.

Anyway, thanks for your quick feedback


piero74 wrote on Friday, March 26, 2010:

Up this discussion.

No other answers? please i need help!

woops_ wrote on Friday, March 26, 2010:

A long application note with example code is not enough? What are you expecting?

piero74 wrote on Friday, March 26, 2010:

In the app note above, there isn’t anything related to USB.
I’m asking if someone is already worked with USB stack with FREERTOS.


petermeier wrote on Friday, March 26, 2010:

Hi Piero,
the USB Stack only uses one interrupt (if you use host mode only - like for USB sticks). You need to wrap this ISR in the style FreeRTOS needs it (there is a good example in the FreeRTOS package included). Next step is that you call once USBInitialize(0) when FreeRTOS is already running.  After that you just need to call USBTasks() periodicly every 1…10ms (as you like). If you use a filesystem like FatFS from Chan there is a ready semaphore handling included - so you don’t need to worry about access rules from different tasks because FatFS will handle that.
If you use the MSD_SCSI functions for reading/writing  a sector, think about this:
These functions normally block the statemachine processing (as the USB stack from Microchip is being designed). But these functions need a handling of the USBTasks() - so Microchip decided, to make the handling quite easy - to include the calling of USBTasks() in the blocking functions. And here you need to remove the call to USBTasks() because in your main-task USBTasks() will be already the called periodicly.

Hope that helps a little.