Hello World help please 18F14K50 config


Closed Thread
Results 1 to 12 of 12

Hybrid View

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


    Did you find this post helpful? Yes | No

    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

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


    Did you find this post helpful? Yes | No

    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.

Members who have read this thread : 0

You do not have permission to view the list of names.

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