Need Help with USB using PIC18F2455


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1

    Default Need Help with USB using PIC18F2455

    I use EasyHID to generate both PICBASIC code and visual basic code, I connected the cicuit as shown in various posts and schematics, but evey time I plug the usb cable in our laptop or my PC I have a problem "USB Device Not recognized" , I sure that I'm connected the circuit well with 470nF capacitor but the same problem , I think there are a driver I must install or something else.
    I attached my photos for clearing
    Attached Images Attached Images   

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Most problem comes with the ConfigFuse setting, then the code. Is it me.. or i don't any of those here?

    You'll also need to tell us which crystal/resonator speed you have.

    I saw you looked at USBDemo... you didn't find anything to use in?
    Last edited by mister_e; - 14th April 2008 at 20:34.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3

    Default

    Oky here is my code which I use 4MHZ crystal:

    ' Pic Configuration
    ' =================
    asm
    __CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    ; ; ; USB clock source comes from the 96 MHz PLL divided by 2
    ; ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
    ; No prescale (4 MHz oscillator input drives PLL directly)


    __CONFIG _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    ; ; ; Oscillator Switchover mode disabled
    ; ; Fail-Safe Clock Monitor disabled
    ; XT oscillator, PLL enabled, XT used by USB

    __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
    __CONFIG _CONFIG2H, _WDT_OFF_2H
    __CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
    __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    endasm

    DEFINE OSC 48
    ;DEFINE LOADER_USED 1
    symbol led=portb.7
    output led
    USBBufferSizeMax con 8 ' maximum buffer size
    USBBufferSizeTX con 8 ' input
    USBBufferSizeRX con 8 ' output

    ' the USB buffer...
    USBBuffer Var Byte[USBBufferSizeMax]
    USBBufferCount Var Byte

    ' ************************************************** **********
    ' * main program loop - remember, you must keep the USB *
    ' * connection alive with a call to USBService every couple *
    ' * of milliseconds or so... *
    ' ************************************************** **********
    low led
    usbinit ' initialise USB...
    ProgramStart:

    gosub DoUSBIn
    toggle led
    pause 100
    gosub DoUSBOut
    toggle led
    pause 100
    goto ProgramStart

    ' ************************************************** **********
    ' * receive data from the USB bus *
    ' ************************************************** **********
    DoUSBIn:
    USBBufferCount = USBBufferSizeRX ' RX buffer size
    USBService ' keep connection alive
    USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
    return

    ' ************************************************** **********
    ' * wait for USB interface to attach *
    ' ************************************************** **********
    DoUSBOut:
    USBBufferCount = USBBufferSizeTX ' TX buffer size
    USBService ' keep connection alive
    USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
    return

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    this section will cause you a problem
    Code:
    gosub DoUSBIn
    toggle led
    pause 100
    gosub DoUSBOut
    toggle led
    pause 100
    goto ProgramStart
    Why? because of this section
    Code:
    ' ************************************************** **********
    ' * main program loop - remember, you must keep the USB *
    ' * connection alive with a call to USBService every couple *
    ' * of milliseconds or so... *
    ' ************************************************** **********
    The easy way will be to use Darrel's instant interrupts. Here's the famous POST 148
    http://www.picbasic.co.uk/forum/show...&postcount=148
    Last edited by mister_e; - 14th April 2008 at 21:14.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5

    Default

    Iam from begining not include delay of 100ms but I added them to give indication for led about where the code stuck and find that It's stuck in DousbIn subroutine. now I'm removed the delay time and the same problem , I don't know where is the problem ????????????

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Code:
    DoUSBIn:
            USBBufferCount = USBBufferSizeRX ' RX buffer size
            USBService ' keep connection alive
            USBIn 1, USBBuffer, USBBufferCount, TimeOut ' No data?, Getout of here
    TimeOut:
    return
    Do you still have the USB connection error?

    Maybe better to begin with USBDemo and work around with? There's a load of information in that thread (ok ~180 post to read but)
    Last edited by mister_e; - 14th April 2008 at 21:38.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. USB Bootloader.
    By HenrikOlsson in forum USB
    Replies: 22
    Last Post: - 2nd May 2013, 02:46
  3. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  4. One USB keyboard to Two USB Ports
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2009, 00:04
  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 : 0

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