Quote Originally Posted by Darrel Taylor View Post
USBDemo Warning, the example is setup for 13K50/14K50.
Comment the configs, and uncomment the other configs (if needed).
Change ANSELs to ADCON1 (if needed).
I made these changes to the BasicUSB.pbp code for use with 18F4550 as you can see in my listed code below. It compiles OK into a .hex file which I then programmed into the 18F4550 using the PicFlash programmer in my EasyPic6. By all appearances everything was OK until I turned on power to the MCU with Steve's VB6 program running....at that point the USB connection was not recognized and nothing else happened. Can you look at this code and tell me what is wrong. I made shure both the include files were in the PBP folder and since it compiled I interpreted that to mean the INCLUDES were OK. Since I was able to get Steve's code to run in my EasyPic6 I believe that eliminates the VB6 code as the problem, so need to figure out how to debug yours and when it doesn't connect or do anything visible, I don't know how to debug it.

I'm not even going to tell you how it works.
I defy you to not understand what it does.
Up until you ask a question.
I studied the code in both the test program and in DT__HID.bas and unfortunately I guess I don't understand what it does since I can't get it to work. I need your HELP.
Code:
'**********************************
        '*  Name    : BasicUSB.pbp        *
        '*  Author  : Darrel Taylor       *
        '*  Notice  : Copyright (c) 2009  *
        '*  Date    : 7/23/2009           *
        '*  Version : 1.0                 *
        '*  Notes   :                     *
        '*          :                     *
        '**********************************
;--- if you un-comment these, you must comment the ones in the .inc file ---
ASM  ; 18F2550/4550, 8mhz crystal as used in EasyPic6
   __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
   __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
   __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
   __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
   __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM

ASM  ; 18F13K50/14K50  Only 12mhz crystal can be used for USB
;    __CONFIG    _CONFIG1L, _CPUDIV_NOCLKDIV_1L & _USBDIV_OFF_1L
;    __CONFIG    _CONFIG1H, _FOSC_HS_1H & _PLLEN_ON_1H & _PCLKEN_ON_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
ENDASM

DEFINE OSC 48
clear

;--- Setup Interrupts ------------------------------------------------------
INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System

ASM
INT_LIST  macro    ; IntSource,          Label,  Type, ResetFlag?
        INT_Handler   USB_Handler
    endm
    INT_CREATE               ; Creates the interrupt processor
endasm

;--- Setup USB -------------------------------------------------------------
INCLUDE "DT_HID260.pbp"

DEFINE USB_VENDORID    6017
DEFINE USB_PRODUCTID   2000
DEFINE USB_VERSION     1
DEFINE USB_VENDORNAME  "Darrel Taylor"
DEFINE USB_PRODUCTNAME "DT_HID"
DEFINE USB_SERIAL      "001"
DEFINE USB_INSIZE      32   ; IN report is PIC to PC (8,16,32,64)
DEFINE USB_OUTSIZE     16   ; OUT report is PC to PIC
DEFINE USB_POLLIN      10   ; Polling times in mS, MIN=1 MAX=10
DEFINE USB_POLLOUT     10

; --- Each USB LED is optional, comment them if not used ----
DEFINE USB_LEDPOLARITY 1       ; LED ON State [0 or 1]  (default = 1)
DEFINE USB_PLUGGEDLED  PORTB,0 ; LED indicates if USB is connected
DEFINE USB_TXLED       PORTC,2 ;  "      "     data being sent to PC
DEFINE USB_RXLED       PORTC,1 ;  "      "     data being received from PC

OutCount    VAR  WORD : OutCount = 0
Value       VAR  WORD
X           VAR  WORD

;--- Setup ADC -------------------------------------------------------------
DEFINE ADC_BITS 10  ; Number of bits in ADCIN result
ADCON2.7 = 1        ; right justify    (Change this if ADFM in diff register)
ADCON1 = %00010000  ; AN4/RC0 Analog
'ANSELH = 0

;--- The Main Loop ---------------------------------------------------------
Main:
    FOR X = 0 to 1000           ; Check for incomming USB data while pausing
@     ON_USBRX_GOSUB  _HandleRX
      PAUSE 1
    NEXT X
    
    ADCIN 4, Value
    OutCount = OutCount + 1
    ARRAYWRITE USBTXBuffer,["AN0=",DEC Value," -",DEC OutCount,"  "]
    IF Plugged THEN GOSUB DoUSBOut     ; only send when USB is connected
GOTO Main

;---- This just sends the received packet back to the PC -------------------
HandleRX:
    ARRAYWRITE USBTXBuffer,[STR USBRXBuffer\USBBufferSizeRX]
return