Jump to content
Ian Harris

New Picpack Library W/usb Support - Rc1

Recommended Posts

I've made available the first release candidate for the new version of the PicPack library for the SourceBoost compiler. It has native, non-Microchip stack support for USB pics, including examples of a mouse and a USB serial port. These are based on the 18f4550, and I've been using the TechToys prototype board.

 

It needs some tidying up, documenting and no doubt, bug fixes, but I wanted to make it available to the adventurous to have a play with and give me some feedback - much appreciated guys. Final version will be out shortly, along with USB tutorials, etc.

 

Enjoy.

 

http://embeddedadventures.blogspot.com

Share this post


Link to post
Share on other sites

this could be the beginning of something big. thanks a lot, will check it out as soon as I can get to it.

 

Russ

Share this post


Link to post
Share on other sites

Hi Ian,

Thanks for writing this code.....some non Microchip (and associated licence issues) code that does CDC has been much waited for. I've been using a modified version of the Microchip CDC code for a while, and it's been quite aggravating I cannot release the code because of the Microchip license (search the forums for threads on this).

 

I've managed to get the code to compile, though not run yet as my hardware is a little different from yours I think.

 

If I may make some suggestions for the next release candidate to make it more general:

- Have some way of turning off all serial port debug functions. In my system I don't have a RS232 serial port, and the pins are actually being used for something else. Debug functions should be able to be compiled or not compiled depending on a #define switch.

- Implement the code as a library, so it can be included in the project as a block of code without complicating the actual implementation. In the library don't have any code specific to any other peripherals (like a serial port), specific interrupt timers or i/o pins unless #define switches are turned on.

- Implement a USB receive buffer set of functions, including a cdc_kbhit to check if a character has been received, but not extracting it from the buffer (helps in user interfaces).

- allow the option of non blocking and blocking cdc functions. For example when transmitting cdc data, the characters go out to a buffer and get sent automagically by interrupt.

- bundle any debug, bus power, blocking etc #define switches plus the PID/VID codes into a seperate identifiable file.

- If possible have the rx/tx buffers user definable in the above bundle...some applications need to transmit long blocks, sometimes dont

- have flushing functions for the buffers, sometimes a user might abort a long download

- as a stretch goal, use the usb interrupts rather than a timer based interrupt approach, freeing up timers for other uses.

 

In a library based implementation may I suggest the following approach:

 

1) Have an error code function to return status of the USB, connection/disconnection etc instead of debug to serial port

2) Have an error code function to return the status of USB buffer rx/tx buffers, buffer overflow, empty, length of data etc instead of only serial debug

3) de-couple your interrupt based functions, so a simple call from an interrupt can do USB servicing. This allows the user to use their own interrupt functions, for example in my application I need some A/D operations to be done as a higher priority to the USB servicing....I'd prefer to setup my own interrupt functions. Some users may wish to call the cdc service function manually in a main loop, or turn on/off their usb activities depending on whether a cable is connected to save power (I sense the 5V pin via a resistor divider, and only turn on the USB stuff when needed).

4) some functions to turn off/on usb cleanly (my code is a bit iffy here)

 

As a start I've attached a stripped down set of files. The files cdclib.c and cdclib.h are in the library and exposed to the user, based on the modified Microchip code mentioned above. The rx part of the code is a bit mangy sorry...but I hope you get the idea.

 

The other two files show an example using the library. My library also has a bunch of functions for making menus and navigating them in hyperterminal which you might see in the attachment. The app can be controlled by hyperterminal, or by a custom host program but usually runs standalone (its a data logging application).

 

If you like PM me and we can work on a library based implementation together. My goal is a black box library that hides all the complexities and lets me concentrate on the application only. I just need a CDC engine to drive it, preferably a non Microchip implementation so it can be shared.

 

Phil

cdclib.zip

Share this post


Link to post
Share on other sites

Hi Ian,

 

I constructed my board last weekend and tested the hardware with the Microchip Bootloader & MCHPFSUSB Demo code. The hardware works fine for the MCHPFSUSB demo. I have not tested the Micochip CDC firmware on the board.

 

I have compile the PIC Pack Rc1 demo however, it does not enumerate on the USB Bus (yet).

 

The RS232 portion works, I get the messages and can input the a command.

 

I don't attach to the USB - and when I de-attach I get to: serial_print_str(" don't own it! ");

 

Can you recommend a USB Sniffer to use in order so see if data is flowing IN/OUT and help to start the debug process?

 

I also assume that when we enumerate we are going to use the CDC driver form (which will then create a standard serial port):

 

x:\MCHPFSUSB\fw\CDC\inf\win2k_winxp

 

I attach my schematic and board for reference and for other users who would like to get started with USB.

 

Anyway - it is exciting stuff, the posibilities are great. Let's see how we go forward.

post-3647-1217495734_thumb.jpg

Edited by RSABear

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...