USB CDC Communications for Dummies!


Closed Thread
Results 1 to 40 of 105

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Posts
    8

    Default

    is theare any other way to make it working because i cannot to it working with this way....!!!!

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    Quote Originally Posted by davids View Post
    is theare any other way to make it working because i cannot to it working with this way....!!!!
    There are lots of ways to make it work, but they all involve servicing the usb at a regular interval. Using Darrel's interrupts would do this in the background, and still allow you to use your Pause 1000. http://www.picbasic.co.uk/forum/show...0682#post30682 What keeps you from being able to use this method?

    A not so good way to do it would be to create a loop.

    Code:
    For i = 1 to 250   'Loop 250 times X 4ms = 1000ms
      Pause 4       'Pause 4 ms
      USBService     'Service that USB connection
    Next i
    A better way to do it (if you still could not use usb service interrupt) would be to use a timer and control a "pause" with that.

    Disclaimer: I have only once played with USB demo, so if anything I say is bogus, I am sure the experienced will correct this.
    http://www.scalerobotics.com

  3. #3
    Join Date
    Jun 2009
    Posts
    8

    Default

    is it possible to control usb printer (label dymo) from pic 18f 4550???
    Last edited by davids; - 3rd August 2009 at 11:00.

  4. #4
    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).

  5. #5
    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, 20:17
  2. One USB keyboard to Two USB Ports
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2009, 00:04
  3. USB CDC help..
    By jchandir in forum USB
    Replies: 6
    Last Post: - 22nd November 2008, 21:23
  4. Replies: 4
    Last Post: - 5th November 2008, 16:21
  5. USB PIC without USB Connection
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th December 2005, 17: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