USB CDC Communications for Dummies! - Page 2


+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 105
  1. #41
    Join Date
    Jun 2009
    Posts
    8

    Default

    everything is working perfect i have connect it with labview but when i am using PAUSE 1000 nothing is working !!!!!!!

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

    Default

    Its the:

    Code:
    USBService ' Must service USB regularly
    part. It must be serviced every 10 ms, or your communication will drop. So your pause 1000 is about 100 times too long. Some people have used Darrel's interrupt routines for the service interval. Here is one link:

    http://www.picbasic.co.uk/forum/show...5302#post45302
    http://www.scalerobotics.com

  3. #43
    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....!!!!

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

  5. #45
    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.

  6. #46
    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).

  7. #47
    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

  8. #48
    Join Date
    Nov 2009
    Location
    Australia
    Posts
    10

    Default USB Device Not Recognised

    G'Day,
    Used Mecanique cct(20M 18F4550) and PBP2.6 and after adding

    @ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    and then enabling VREGEN config bit got the Windows USB Device Not recogised message.
    Are there any other config bits that have to be changed.
    Is it possible to get a hex file for this project so I can at lest check my cct.
    tks

  9. #49
    Join Date
    Nov 2009
    Location
    Australia
    Posts
    10

    Smile All Fixed

    G'day (again)
    My problem cured when I added a 10MFD cap on the two 18F4550 power pins.
    I was using the USB 5v to power the card.
    So can now start playing(at last) with USB.
    Grant

  10. #50

    Default nearly there...

    Windows sees a pic18 usb cdc device s inserted, but finds no drivers.

    windows 7 32 bit

  11. #51

    Default

    yes the above error was me stupidly not showing windows device mangler where the right .inf file was, my bad...

    But..

    I am now doing a ' USBIN endpoint, buffer, count, nodatatloop ' every second or so, problem is when I send data to it, I only get it one byte at a time, so reading 'cat' takes 3 seconds......

    count variable is always 1 if data present, so i get 1 three times then it returns to zero

    surely I should get all 3 bytes into my buffer and a value returned of 3 for count.

    I dont lose any chars from my text string in the terminal, i think it buffers and does some form of flow control, but when i copy a text file in a dos/command window, i do lose them, i get a count of one for the first 'C' but then a zero as 'at' have got lost before i got a chance to read them.

  12. #52

    Default

    Ok cant edit the above but it goes like this, if i send 'cat' with hyperterminal or putty i get 3 individual chars at the pic end so need to read 3 times, if i send it from a program written in vb6, i get a 'cat' in one loop/poll etc and a bytecount length of 3, as expected, hope no one else falls foul of this.

  13. #53
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    For anyone using this with WIN7 64 bit here is the *.inf driver file.
    Remove the .txt
    Attached Files Attached Files
    Dave
    Always wear safety glasses while programming.

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

    Default USB CDC_DEMO with DT_INTS

    Here is some PBP 2.60 code (cut and pasted) from Darrel, with the "Hello World" example added in. Darrel's main code is taken from another thread, located here: http://www.picbasic.co.uk/forum/show...4292#post94292 . It uses DT_INTS ( instant interrupts ) to service the USB. As always, DT_INTS can then also be used for all types of other things, while the USB connection is kept alive.

    Click image for larger version

Name:	schematic-large.gif
Views:	11492
Size:	28.8 KB
ID:	5042

    Code:
    '  Compilation of this program requires that specific support files be
    '  available in the source directory.  For detailed information, see
    '  the file PBP\USB18\USB.TXT.
    
    '  Config files for PIC18F4550 with 20 mhz crystal
    
    asm
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_3_2L & _VREGEN_ON_2L
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
            __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
    endasm
    DEFINE OSC 48
    
    INCLUDE "cdc_desc.bas" 'Descriptor file    for CDC    serial demo
    
    ;--- Setup Interrupts ------------------------------------------------------
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"  ; Include if using PBP interrupts
    buffer    Var    Byte[16]
    cnt    Var    Byte
    ASM
    INT_LIST  macro     ; IntSource,          Label,  Type, ResetFlag?
            INT_Handler     USB_INT,  _DoUSBSERVICE,   ASM,  yes
            INT_Handler     INT_INT,    _Handle_INT,   PBP,  yes
        endm
        INT_CREATE             ; Creates the Low Priority interrupt processor
    
        ;INT_ENABLE  USB_INT   ;we will do this after we initialize USB
        INT_ENABLE  INT_INT
    ENDASM
    
    
    ;----[Initialise USB and Interrupts]----------------------------------------
        PAUSE 100                    ; Allow VUSB to stabilize
        USBINIT                      ; initialize the USB driver
        USBSERVICE                   ; service it once
        UIE = $7F                    ; enable USB interrupts
        UEIE = $9F                   ; enable USB Error interrupts
    @   INT_ENABLE  USB_INT
    
    ;----[Main program loop]----------------------------------------------------
    Main:
        cnt = 16        ' Specify input buffer size
        USBIn 3, buffer, cnt, main
    
    ' Message received
        buffer[0] = "H"
        buffer[1] = "e"
        buffer[2] = "l"
        buffer[3] = "l"
        buffer[4] = "o"
        buffer[5] = " "
        buffer[6] = "W"
        buffer[7] = "o"
        buffer[8] = "r"
        buffer[9] = "l"
        buffer[10] = "d"
        buffer[11] = 13
        buffer[12] = 10
        buffer[13] = 0
    
    outloop:
        USBOut 3, buffer, 14, outloop
    
    GOTO Main
    
    ;----[Interrupt handler -- Service USB]-------------------------------------
    DoUSBSERVICE:
          USBSERVICE                   ; Run the SERVICE routines
    @ INT_RETURN
    
    ;----[Interrupt handler -- INT]
    Handle_INT:
     ; something here
    @ INT_RETURN
    Last edited by ScaleRobotics; - 31st December 2010 at 19:51.
    http://www.scalerobotics.com

  15. #55
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219

    Default Doesn't want to play!

    Using PBP 2.60A and MPASM for my 1st attempt with USB on a PIC18F2455, I followed these directions:
    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.
    Copied complete USB18 folder to Documents\MCS to work with.

    Wouldn't even start to compile
    1st error: Variable USBReserveMemory position request 1024 beyond RAM_END 1023
    Did: Opened up PIC18F2455.BAS and enabled BANK4

    Started compiling! only to end in errors...
    2nd error: ERROR 180.....mcs\usb18\usb18mem.asm 116: RES directive cannot reserve odd number of bytes in PIC18 absolute mode
    ERROR 231....usb18mem.asm 116: no memory has been reserved by this instruction
    This was repeated for many lines.
    Did: Looked at usb18mem.asm line 116 and 117 and on and could only stare.
    Code:
    ; (See usbctrltrf.c)
    ctrl_trf_state	res	1		; Control Transfer State
    ctrl_trf_session_owner res 1		; Current transfer session owner 
    wCount		res	2		; Data counter
    Now what?
    Reading through the forum for this problem and it seems I'm the only one? Can't be that special. Can someone please help a dude out?
    Louie

  16. #56
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    The USB files need to be in the same directory as your project and it works best if each project has a directory of its own.

    Does this example help any?
    http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
    Dave
    Always wear safety glasses while programming.

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

    Default

    Quote Originally Posted by LinkMTech View Post
    Wouldn't even start to compile
    1st error: Variable USBReserveMemory position request 1024 beyond RAM_END 1023
    Did: Opened up PIC18F2455.BAS and enabled BANK4
    Are you sure you are working with 2.60 files?

    The BAS file should look like this to start with (no modifications required):

    Code:
    '****************************************************************
    '*  18F2455.BAS                                                 *
    '*                                                              *
    '*  By        : Leonard Zerman, Jeff Schmoyer                   *
    '*  Notice    : Copyright (c) 2008 microEngineering Labs, Inc.  *
    '*              All Rights Reserved                             *
    '*  Date      : 09/12/08                                        *
    '*  Version   : 2.60                                            *
    '*  Notes     :                                                 *
    '****************************************************************
    
    BANKA   $0000, $005F
    BANK0   $0060, $00FF
    BANK1   $0100, $01FF
    BANK2   $0200, $02FF
    BANK3   $0300, $03FF
    BANK4   $0400, $04FF
    BANK5   $0500, $05FF
    BANK6   $0600, $06FF
    BANK7   $0700, $07FF
    'EEPROM  $F00000, $F000FF
    LIBRARY "PBPPIC18"
    
            include "PIC18EXT.BAS"
    
    PORTL   VAR     PORTB
    PORTH   VAR     PORTC
    TRISL   VAR     TRISB
    TRISH   VAR     TRISC
    
            include "PBPPIC18.RAM"
    USBMEMORYADDRESS Con    $400    ' USB RAM starts here
    
    '*-----------------------* EOF 18F2455.BAS *--------------------*
    Last edited by ScaleRobotics; - 10th January 2011 at 01:52.
    http://www.scalerobotics.com

  18. #58
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219

    Default

    Thanks Dave, I'm gonna study the project for more insight.

    Are you sure you are working with 2.60 files?
    Just checked the files I have and nope! It's version 2.46!
    When I upgraded to 2.60 recently I also downloaded the patch that included the missing PIC18's. Where did I miss getting the latest 2.60 files?

    Okay just did some more digging and found the latest 18F2455.bas in the PBP folder not in the USB18 folder. Will keep looking for the rest.
    Last edited by LinkMTech; - 10th January 2011 at 15:08. Reason: Found some files
    Louie

  19. #59
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219

    Default Looks promising

    Okay, just copied the 18F2455.bas ver. 2.60 from the PBP folder over to the USB18 folder to replace the ver. 2.46 and it compiled 100%!
    Fingers are twitching, but need to wait until the coast is clear here before I can test it.

    Thank you for the help.
    Louie

  20. #60
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    You can have more than one version of PBP installed.
    I have directories
    C:\PBP_247
    C:\PBP_250
    C:\PBP_260

    Then "point" to the version I want from MCS or FineLine or what ever I am using to invoke the compiler.

    So you may want to try a fresh install...
    Dave
    Always wear safety glasses while programming.

  21. #61
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219

    Default Got the "ding ding"!

    Have heard it so many times before but never from this... what a giddy difference!
    To summarize this endeavor:
    Make sure 18F2455.bas revision is latest 2.60, found in PBP folder not the file in USB18 folder.
    Never assume a copy/pasted Config list is correct! Print out the .inc file for the chip found under MPASM Suite and go through each setting. That's how I found out why there was 0V on VUSB! Turn ON the VREG!
    Code:
    @   __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @   __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    @   __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_SOFT_2L & _BORV_2_2L & _VREGEN_ON_2L 
    @   __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @   __CONFIG    _CONFIG3H, _CCP2MX_OFF_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H
    @   __CONFIG    _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L
    I think I've the USB bug now. Thanks for the infection!
    Louie

  22. #62
    Join Date
    Dec 2006
    Posts
    32

    Default Re: USB CDC Communications for Dummies!

    Hi Guys,

    Malc_c and myself are tinkering with a little project and while he's attacking the hardware side, im looking at the communication side of things and could do with a bit of info for this:

    the software on the PC (Not written by us, but freely available for people to use) uses the serial port to communicate to the external circuitry and the way it toggles things is by using the RTS and DTR pins setting them either high or low.

    Now my question is we want to setup a PIC18F via USB to be the toggle so thought the CDC comms would be an ideal springboard and I was wondering if when the pic is setup cia CDC comms can the USB detect the RTS/DTR signals? as the programs on the PC dont actually send 'data' but just use those 2 pins to toggle pins on an external device.

    Reason we want to use USB is for new machines (ie laptops/netbooks etc) that dont have parallel or serial ports, but still be able to utilise the software as there are quite a few differrent programs that all do the same thing (basically trying to bring the 21st century to the masses LOL!!!! )

    Many thanks in advance,

    Mark.

  23. #63
    Join Date
    Oct 2009
    Posts
    582

    Default Re: USB CDC Communications for Dummies!

    Just to add to Mark's post, we both know that a USB to serial cable works, but we're looking for a simplified modification than the current solution.

    The original mod was designed to work with the parallel port, but later someone adapted this to serial using a three transistor / diodes and a handful of 10K resistors circuit. From what we can deduce it uses the DTR and RTS lines as level shifters, and the transistors as a simple switch so that it makes / breaks connections on the modified commercial PCB.

    Hope that helps

    Malcolm

  24. #64
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    Trying to use 18F67J50. Trying to get this to work with a PIC_LCD3310. Followed all DT's instruction's for PBP2.60.

    Using default configs, 20Mhz Xtal (I think). Program compiles fine. PK2 software writes it to the uP. Plug the USB in and nothing. No DE-DE.

    Now I have been using this setup for other stuff, so I assume its not the hardware. Doesn't mean its not, but got to assume something. So first question, does anyone know if the default configs will work for this?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  25. #65
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: USB CDC Communications for Dummies!

    The default config in the PBP directory looks correct for a 20MHz external.
    Can you confirm that the chip is running at 48MHz?
    Dave
    Always wear safety glasses while programming.

  26. #66
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    I can't confirm it right now, but I feel it is. I have been playing with receiving serial at 115K without any problems. But I was using configs set in code. I also tried those same configs, still nothing. I will double check all configs tonight.

    Thank you for verifing the defaults should work. I know Darryl said not to mess with the code until it connected, but I think I can at least toggle a pin to make sure there is life, and at what speed.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  27. #67
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: USB CDC Communications for Dummies!

    Post your code. Maybe there is something else.
    Dave
    Always wear safety glasses while programming.

  28. #68
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    Here it is:
    Code:
    ' USB sample program for PIC18F4550 CDC serial port emulation
    '  Requires PBP 2.60 or later
    '  Compilation of this program requires that specific support files be
    '  available in the source directory.  For detailed information, see
    '  the file PBP\USB18\USB.TXT.
     Include "cdc_desc.bas" ' Include the HID descriptors
    Define  OSC     48
    buffer Var Byte[16]
    cnt Var Byte
    
     OSCTUNE.6 = 1  ' Enable PLL for 18F87J50 family
     Pause 10
     USBInit   ' Get USB going
    ' Wait for USB input
    idleloop:
     USBService  ' Must service USB regularly
     cnt = 16  ' Specify input buffer size
     USBIn 3, buffer, cnt, idleloop
    ' Message received
     buffer[0] = "H"
     buffer[1] = "e"
     buffer[2] = "l"
     buffer[3] = "l"
     buffer[4] = "o"
     buffer[5] = " "
     buffer[6] = "W"
     buffer[7] = "o"
     buffer[8] = "r"
     buffer[9] = "l"
     buffer[10] = "d"
     buffer[11] = 13
     buffer[12] = 10
     buffer[13] = 0
    outloop:
     USBService  ' Must service USB regularly
     USBOut 3, buffer, 14, outloop
     Goto idleloop  ' Wait for next buffer
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  29. #69
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    revisied code with a speed test added
    Code:
    ' USB sample program for PIC18F4550 CDC serial port emulation
    '  Requires PBP 2.60 or later
    '  Compilation of this program requires that specific support files be
    '  available in the source directory.  For detailed information, see
    '  the file PBP\USB18\USB.TXT.
     Include "cdc_desc.bas" ' Include the HID descriptors
    
    Define  OSC     48
    trise.3 = 0
    buffer Var Byte[16]
    cnt Var Byte
        
     OSCTUNE.6 = 1  ' Enable PLL for 18F87J50 family
     Pause 10
    '*****************************************
    '--------------Speed test 
     
    speedtest:
        toggle porte.3
        goto speedtest
     
    '--------------End test
    '******************************************    
        
        USBInit   ' Get USB going
    ' Wait for USB input
    idleloop:
        
     USBService  ' Must service USB regularly
     cnt = 16  ' Specify input buffer size
     USBIn 3, buffer, cnt, idleloop
    ' Message received
     buffer[0] = "H"
     buffer[1] = "e"
     buffer[2] = "l"
     buffer[3] = "l"
     buffer[4] = "o"
     buffer[5] = " "
     buffer[6] = "W"
     buffer[7] = "o"
     buffer[8] = "r"
     buffer[9] = "l"
     buffer[10] = "d"
     buffer[11] = 13
     buffer[12] = 10
     buffer[13] = 0
    outloop:
     USBService  ' Must service USB regularly
     USBOut 3, buffer, 14, outloop
     Goto idleloop  ' Wait for next buffer
    the results of the speed test: pin toggles at 3Mhz. To be clear, there is .3333uS between toggles. Now I don't feel like that is correct. lets see: 48Mhz=12Mips. So thats .08uS per instruction? So we are executing 4 instructions? Hmm, that doesn't sound right.

    Ok, I will see if someone else can think better then I this evening
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  30. #70
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: USB CDC Communications for Dummies!

    Might be a problem with the buffer size compared to the data being sent. They are different sizes.

    Here is an example:
    Code:
    Buffer    VAR BYTE[16]
    Cnt       VAR BYTE
    B0        VAR BYTE
    B1        VAR BYTE
    
    ADCON1 = 15               ' Set all I/Os to Digital      
    CMCON = 7                 ' Disable Comparators
    Cnt = 16 
      
    for b0 = 0 to 15
        lookup b0,["USB CONNECTED!",10,13],B1 
        BUFFER(B0) = B1
        NEXT B0
     USBINIT 
    ' Main Program Loop
    Loop:
        USBService        ' Must service USB regularly
        USBOut 3, Buffer, Cnt, loop
        goto loop
    As for your speed test... my brain is ready to fuss out for the day also...
    Dave
    Always wear safety glasses while programming.

  31. #71
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    Hmmm.. I would think OS should still see it as a new device even if thats the case.

    Well I am studing the schematic now, I am not sure I have the "CAP" on Vusb. But I can say this thing works with a USB bootloader no problem. Now does that mean winblows will see it? IDK

    I see there are pullups on the data lines. And according to the datasheet, The internal pullups must be disabled. I have been looking at the include file, and I think there are being set.

    I am just about to give up on this "pre-configured" answer. After all, it may NOT be the answer for this chip anyway. I will start looking at your solution to see if I can make that work.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  32. #72
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: USB CDC Communications for Dummies!

    The VUSB cap is a must.
    I have not used the chip you are using. do you have a 4550 or 2550?
    Dave
    Always wear safety glasses while programming.

  33. #73
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    In case any one wants to look, here is the schematic and "manual" seeing how I am having trouble with anything tonight, (the pullups do not exist on the board), Maybe I should give this one a break for a bit.

    No, I don't have any of those chips. I was hoping to be able to get this to work on a premade board. Seems like it should be possible. One thing I don't like, with the ready made code provided by melab, It takes more time to chase down what is ( or is not) going on.

    Does it make sense that if I can use microchips USB bootloader, the hardware side of things are ok?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  34. #74
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: USB CDC Communications for Dummies!

    Looks like that board can be powered from the USB port. Is that what you are doing? If so, try powering it from another source.

    Are you connecting the board for testing to the same machine PBP is on? If not, did you copy mchpcdc.inf to the PC?
    Dave
    Always wear safety glasses while programming.

  35. #75
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    So far I have tried powered from USB, and powered from PK3. It is on the same PC as PBP, but it is a win7/64 machine. I see earlier you posted an update for win 64 machines and that file. While I haven't downloaded that yet, I would still expect to get the de-dum when I plug in the cable. Even if win can't figure out what to do with it.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  36. #76
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: USB CDC Communications for Dummies!

    If the correct driver is not there the PC will not ding dong. It will just sit there or if you are lucky it will say it does not know what is plugged in. If you have PBP 2.6 you hqve the file needed for win 64. I think.
    Dave
    Always wear safety glasses while programming.

  37. #77
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    Well I have PBP 2.6C, So I think I must have all the proper files. I copied the entire contents of the USB18 folder to a new folder. started MCS, selected PIC18F67J50. Opened cdc_demo.pbp from the new folder. Hit compile, all was fine. programed chip. plugged in USB and waited. for at least 10 seconds. no indication from PC that I had plugged it in.

    Now I listed these step just to be clear that is ALL I did. If I need to move a .inf file somewhere, or anything else like that, I have not done it.

    On a side note, thought I would distract myself by installing VB 2010 express. Well that has also been FAIL! I am thinking I need to throw all this new crap in the trash and bust out an old dos machine. (yes I have some) I bet PBP will even run on that.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  38. #78
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    Found this on another forum:
    The Microchip pic67j50 has a different USB ram location to standard USB devices. I know Les did do a conversion of the USB code for me and I got it to work with basic hid and CDC
    Not sure if this could have anything to do with this. But at least I have a new place to look. Here I come RAM
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  39. #79
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: USB CDC Communications for Dummies!

    Well some success today! Thanks to Walter (scalerobotics) and post #57 of this thread, I have a working CDC on a 18F47J53.

    I am not sure I will keep trying to get this to work on the PIC_LCD3310, I will play with this for a while I think.

    Thank you all who helped with this VERY painful task.

    BTW, what speed should I think my "COM" port is running at, any ideas?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  40. #80
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: USB CDC Communications for Dummies!

    Just curious about post 57. What helped?
    Dave
    Always wear safety glasses while programming.

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

Posting Permissions

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