USB CDC Communications for Dummies!


Closed Thread
Results 1 to 40 of 105

Hybrid View

  1. #1
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Default

    Nope, the Pic is a USB slave device, same with the USB printer.

    So in a nutshell, Slaves (mice, printers, PIC) are connected to master devices (PC).

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default CDC with PBP 2.60

    If you are using PBP 2.50 or previous, disregard this post and use Squibcake's example at the beginning of this thread.
    But you can still use USB_ASM_Service.pbp mentioned at the end of this post with Squibcake's example for easier servicing.

    If you are using PBP 2.60, This might help.

    With PBP 2.60, the way USB works has changed significantly.
    You no longer need all those .inc .bas or .bal files for each chip, it automatically works with whatever chip you are using. The Ram usage is only 1 Bank now, which frees up a whole bunch of memory for your program. The asm routines have been optimized to only include what is needed for that protocol, which frees up more program space. All in all, they are just better.

    And the best part is ... they're easier too.
    There's an example from meLabs that works straight out of the box.

    Copy the PBP\USB18 folder to a new location.
    You do not want any files left over from previous versions of PBP, so don't try to copy it into an existing project folder.

    Open and compile cdc_demo.bas with the proper chip selected.
    Program the chip and test. Done deal.

    When windows prompts you to install a driver, point it to the mchpcdc.inf file in the same folder.
    Open a terminal program like HyperTerminal or equivelent and connect to the new COM port at any baud rate, it doesn't matter.
    Press a key, and you should see "Hello World" returned.

    Default configs are for a 20 Mhz crystal with 48 Mhz CPU (18F2455/2550/4455/4550 series).
    18F13K50/14K50 must use 12Mhz crystal only.
    0.22uF or higher capacitor must be on VUSB pin.

    If it works, change the program as desired.
    Don't change the program till it works ... it will work (if the hardware and configs are right).

    NOTE: Long PAUSEs and USB don't mix.
    Anything more than 10mS or so between servicing will cause the PC to disconnect the device.

    Or you can add ...
    Code:
    INCLUDE "USB_ASM_Service.pbp"  ; USB Init and Service interrupt routines
    and not worry about USBINIT or USBSERVICE at all.

    USB_ASM_Service.pbp
    http://www.picbasic.co.uk/forum/show...06&postcount=6

    Cheers,
    DT

Similar Threads

  1. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 21:17
  2. One USB keyboard to Two USB Ports
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2009, 01:04
  3. USB CDC help..
    By jchandir in forum USB
    Replies: 6
    Last Post: - 22nd November 2008, 22:23
  4. Replies: 4
    Last Post: - 5th November 2008, 17:21
  5. USB PIC without USB Connection
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th December 2005, 18:39

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts