Hello World help please 18F14K50 config


+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77

    Default Hello World help please 18F14K50 config

    Hi all, can anyone check my config in the picture below..

    I am trying to get a 18f14k50 usb to work but I just keep getting the 'USB Device not recognized' message from windows.

    I'm using a lab-x1 board with the clock set to 12mhz and the config settings below
    Can anyone give a hello world example or config that will get this device going, I've been at it all day and I'm going nuts lol
    Ps: i've read the datasheet and the other postings about config, i'm no wiser.

    Name:  config.jpg
Views: 1294
Size:  122.5 KB
    Reading the datasheet & understanding it are two different things.

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

    Default Re: Hello World help please 18F14K50 config

    You might try looking at Darrel's sample here: http://www.picbasic.co.uk/forum/show...0434#post80434

    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

  3. #3
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77

    Default Re: Hello World help please 18F14K50 config

    Thanks for sharing that config, I tried it but it does not work, I still get the device not recognized message, any ideas ?
    Reading the datasheet & understanding it are two different things.

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

    Default Re: Hello World help please 18F14K50 config

    I am on a dial-up connection right now, so it's sort of painful to look it up myself. But I didn't think the X-1 was made for the 14K50? You might try looking at the schematic for the low pin count 14k50 board from Microchip, and note any differences. It sounds like a hardware issue, as the code from Darrel definitely works.
    Last edited by ScaleRobotics; - 3rd August 2011 at 18:12.

  5. #5
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77

    Default Re: Hello World help please 18F14K50 config

    Hi yeah dial-up can be a pain.

    I used the prototype area on the lab-x1 for the 14k50, I tried darrels code and it gives the same problem but darrels code does not tell you what config settings to use ?.
    Reading the datasheet & understanding it are two different things.

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

    Default Re: Hello World help please 18F14K50 config

    I think it does show most of the configs to use:

    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, 20mhz crystal
    ;   __CONFIG    _CONFIG1L, _PLLDIV_5_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)
    ANSEL = %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

  7. #7
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77

    Default Re: Hello World help please 18F14K50 config

    Hi, yes, I just noticed that, ok I copied that config into the program and also into the INC file and still device unrecognized :-(
    Reading the datasheet & understanding it are two different things.

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

    Default Re: Hello World help please 18F14K50 config

    Have you looked at the schematic for the low pin count kit, and compared it to what you have? http://ww1.microchip.com/downloads/e...Doc/41356B.pdf

    Are you applying power to the Vusb like the schematic?

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

    Default Re: Hello World help please 18F14K50 config

    What code are you using for the usb part? DT_HID260.pbp, withDT_INTS-18.bas or something else?

  10. #10
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77

    Default Re: Hello World help please 18F14K50 config

    Hi, I am going to check the vusb voltage today, the 18f14k50 / 13k50 is the cheapest usb part ?.
    Reading the datasheet & understanding it are two different things.

  11. #11
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77

    Default Re: Hello World help please 18F14K50 config

    Ok, it is now working :-), the config from darrel's code above works, the problem was something to do with my PC, when I turned it on this morning and plugged im my 14k50 it enumerated straight away, it looks like my pc had become corrupted somehow from using a bad configuration previously.

    anyway, thanks to scalerobotics for your help :-)

    ps: scalerobotics, would it be ok to PM you with another 14k50 question perhaps ?

    Thanks again
    Reading the datasheet & understanding it are two different things.

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

    Default Re: Hello World help please 18F14K50 config

    That's great! Glad you got it working.

    Sure, PM me anytime.

    -Walter

Tags for this Thread

Posting Permissions

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