HID USB on 18F87J50


Closed Thread
Results 1 to 40 of 57

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    737

    Default HID USB on 18F87J50

    Does someone have example for this PIC?
    I can't get it to work...

  2. #2
    Join Date
    Sep 2009
    Posts
    737

    Default Re: HID USB on 18F87J50

    I searched the whole forum and I only found examples for the PIC18f2550 and 4550.
    Does PBP2.60 support USB on 18F87J50?
    For the second day of trying all possible examples and with all possible fuse configuration but nothing show in device menager, not even device not recognised...
    I bought this development system from mikroe, thinking that the is a hardware problem, but still nothing...
    What are my other options
    Last edited by pedja089; - 15th August 2011 at 16:53. Reason: Link repair

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

    Default Re: HID USB on 18F87J50

    Should work. I had the 18F67J50 (same family) running CDC. I can try to get an example for it going for HID. By the way, are you using DT_HID260 ? Will try to get something up tonight, or tomorrow morning.

  4. #4
    Join Date
    Sep 2009
    Posts
    737

    Default Re: HID USB on 18F87J50

    Yes, I tried that and DT_HID. But nothing happen if cable is plugged or unplugged.
    For now, CDC will be good starting point.
    I would be very grateful if you could send me CDC example with fuse configuration.
    Thank you very much.

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

    Default Re: HID USB on 18F87J50

    Well, now I am starting to wonder if I ever had it working on CDC. I had a cdc labeled program for it, but what I had does not work. I had a fairly quick time with the 47J53 in CDC as well as HID, but for the 67J50, I can't seem to get either to work, and I have spent a fair amount of time at it.

    These were the configs I used for other programs for the 67J50, which pretty much matches Microchip's HID bootloader software.

    Code:
    'DEFINE LOADER_USED 1
    'DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader
    #config
        CONFIG PLLDIV = 5       ;for 20 mhz chip
        CONFIG XINST = OFF
        CONFIG STVREN = ON    ;stack overflow reset
        CONFIG WDTEN = OFF    
        CONFIG CP0 = OFF    
        CONFIG IESO = OFF    
        CONFIG FCMEN = OFF    
        CONFIG CCP2MX = DEFAULT    
        CONFIG WDTPS = 32768 
        CONFIG CPUDIV = OSC1  ;DIVIDE BY 1 MODE
        CONFIG FOSC = HSPLL
        CONFIG MSSPMSK = MSK5   
    #endconfig
    
    DEFINE OSC 48
    clear
    OSCTUNE.6 = 1  ' Enable PLL for 18F87J50 family
    I will try a few more things, but I wanted to give you a heads up.

  6. #6
    Join Date
    Sep 2009
    Posts
    737

    Default Re: HID USB on 18F87J50

    I try cdc from pbp/usb18 and add config, but still nothing...
    I use 8MHz crystal, so PPLDIV is 2 is that correct?
    What are the chances that the USB module on 3 PIC are broken?

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

    Default Re: HID USB on 18F87J50

    Not very high. But (speaking for myself), the chances of the problem being behind the keyboard is pretty high! Just not sure what I could be missing here, doing it two different ways hid, and cdc, and with a USB bootloader, and without. So I am running out of things I can think of to try....

    Yes, divide by two would be correct for a 8 mhz.

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

    Default Re: HID USB on 18F87J50

    Well, I am not having any luck over here either. Here is my try at using DT_HID260. I have been successful in getting it running on another J chip, the PIC18F47J53, and looking at the two data sheets, the USB doesnt seem to differ much between these two chips. Except on one the USB data memory is below the buffer descriptors, and the other the USB data memory is above the buffer descriptors. The DEV files seem to point to the USB buffer descriptors (67J50 here): USBMEMORYADDRESS Con $400 ' USB RAM starts here

    Here is my code (that does not work)
    Code:
    '***************************************************************************
    '*  Name    : BasicUSB.pbp                                                 *
    '*  Author  : Darrel Taylor                                                *
    '*  Notice  : Copyright (c) 2009                                           *
    '*  Date    : 7/23/2009                                                    *
    '*  Version : 1.x ' Modified by scalerobotics                              *
    '*  Notes   : I tried to edit it to work on a PIC18F67J50 and I failed     *
    '*          : Worked great on other chips, but I can't seem to figure out  *
    '*          : the problem for PIC18F67J50. Board is PIC_LCD3310, which does*
    '*          : work with the USB bootloader,so probably not a hardware issue*
    '***************************************************************************
    'DEFINE LOADER_USED 1
    'DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader
    
    ;--- 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 CPUDIV=NOCLKDIV ; CPU runing at full speed
    ;    CONFIG USBDIV=OFF ; Low speed USB clock diviser disabled, not used here
    ;    CONFIG FOSC=HS ; Use of High Speed crystal oscillator
    ;    CONFIG PLLEN=ON ; Enable PLL multiplier, 12Mhz oscilator x 4
    ;    CONFIG PCLKEN=ON ; Primary clock source is enabled
    ;    CONFIG FCMEN=OFF ; Failsafe clock off
    ;    CONFIG IESO=OFF ; Oscillator switchover mode disabled
    ;    CONFIG WDTEN=ON ; Watchdog timer on
    ;    CONFIG WDTPS=512 ; Watchdog divider is 512
    ;    CONFIG MCLRE=OFF ; Disable MCLR pin, enable RC3
    ;    CONFIG STVREN=ON ; Stack full/underflow will cause reset
    ;    CONFIG LVP=OFF ; Low voltage programming disabled
    ;    CONFIG BBSIZ=OFF ; 512kW block boot size
    ;    CONFIG XINST=OFF ; Extended instruction mode disabled
    ;ENDASM
    #config         ;pic18F67J50 on Olimex PIC_LCD3310 usb board
        CONFIG PLLDIV = 5    ;for 20 mhz crystal
        CONFIG XINST = OFF
        CONFIG STVREN = off    ;stack overflow reset
        CONFIG WDTEN = OFF    ;added
        CONFIG CP0 = OFF    ;added
        CONFIG IESO = OFF    ;added
        CONFIG FCMEN = OFF    ;added
        CONFIG CCP2MX = DEFAULT    ;added
        CONFIG WDTPS = 32768 
        CONFIG CPUDIV = OSC1  ;DIVIDE BY 1 MODE
        CONFIG FOSC = HSPLL
        CONFIG MSSPMSK = MSK5   ;add
    #endconfig
    
    DEFINE OSC 48
    clear
    OSCTUNE.6 = 1  ' Enable PLL for 18F87J50 family
    
    ;--- 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
    '       Configure ADC 
    '       =============
    '   See thread http://www.picbasic.co.uk/forum/showthread.php?t=11128&highlight=18f67j50
    '   for more information about setting analog, and the WDTCON.4 on this chip
    WDTCON.4 = 1   ' Switch to Alternate SFR
    ANCON0_ALT = %10011110
               '  -xx------ Not Implemented
               '  1--1111-- AN7, & AN<4:1> = Digital
               '  -------0- AN0 = Analog
    
    ANCON1_ALT = %11111111
               '  11111111- AN<15:10> = Digital
    
    WDTCON.4 = 0    ' Back to Default SFR
     
    ADCON0 = %00000001
           '  0-------- VCFG1, Vref- 0 = AVss (1=AN2)
           '  -0------- VCFG2, Vref+ 0 = AVdd (1=AN3) 
           '  --0000--- CHS<3:0>, Channel select -- 0
           '  ------0-- Go/Done, don't care for now
           '  -------1- ADON, Enable ADC
                      
    ADCON1 = %10000111
           '  1-------- ADFM, Right justified result
           '  -0------- ADCAL, Normal A/D converter operation
           '  --000---- ACQT<2:0>, A/D Aquisition time = 0 Tad
           '  -----111- ADCS<2:0>, A/D conversion clock = FRC
    ;--- The Main Loop ---------------------------------------------------------
    TRISD = 0
    PORTD.0 = 1   'turn on g sensor
    PORTD.1 = 0   'select scale for g sensor
    PORTD.2 = 0   'select scale for g sensor
    
    
    TRISA = %00000111   'set porta.0, 1, and 2 as inputs
    TRISB = 0
    CM1CON1 = 7   'CM1CON in PBP3 as CM1CON1
    CM2CON1 = 7   'CM2CON in PBP3 as CM2CON1
    TRISC = 0
    TRISE = 0
    pause 100
    ;--- 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 10, 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

  9. #9
    Join Date
    Sep 2009
    Posts
    737

    Default Re: HID USB on 18F87J50

    I try similar thing, but same result.
    So is it possible there are some bug in PBP for this PIC family?

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    I'm looking into it too.
    Trying to build a board.

    But first I have to ask ...
    Do you have VDD (3.3V) tied to VUSB?
    There's no internal regulator on those chips.
    DT

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

    Default Re: HID USB on 18F87J50

    I can't speak for Pedja's board, But I am pretty sure Walter is using the PIC_LCD3310. If so that DOES show Vusb tied to 3.3V on the schamatic.
    -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!

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

    Default Re: HID USB on 18F87J50

    Thanks Darrel. I had some weird behavior in my computer. PBP3 kept defaulting to MPASMX, no mater how I set it, I'd check back, and it was set to MPASMX. So after removing the Microchip directory, and re-installing MPLAB 8.76, I was able to get PBP to settle on C:\Program Files\Microchip\MPASM Suite . Now CDC and HID work for the 18F67J50 with PBP3.0! Thanks for routing that out for us!
    Last edited by ScaleRobotics; - 24th August 2011 at 03:46.

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

    Default Re: HID USB on 18F87J50

    I have installed MPLAB8,76. Now I get CDC to work on 2.60C, but I don't get the same file to work with PBP3.

    But I am wondering where PBP3 is looking for MPLAB or MPASM? 2.60 allowed you to select the location for PBP, and it also allowed you to show it where the assembler was located. In PBP3 I get this option:

    Name:  pbp3.PNG
Views: 1193
Size:  28.8 KB

    How am I supposed to enter them both? Or are they really supposed to be in the same place??

  14. #14
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    In the Start menu, go to All Programs > PBP3 from melabs > MPASM-MPLAB setup.
    It allows you to set the path to MPASM.
    DT

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

    Default Re: HID USB on 18F87J50

    Thanks!

    Yes, I am using Olimex's PIC_LCD3310. Making a board for this family is a little bit of a pain. Darrel, do you want me to send you the Olimex board? I can ship it out tomorrow.

    Walter

  16. #16
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    Thanks Walter, that's a nice offer.

    But I ordered one from sparkfun. They're only 50 miles away so I should have it by friday, shipped ground.
    That's sure easier than building one.

    I'm going to try a 26J50 too.
    The 87J50 may still be a question mark.
    DT

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

    Default Re: HID USB on 18F87J50

    Now that's what I call support! Thanks Darrel.

    I can vouch for the PIC18F46J50 working with DT_HID260 and PBP3. I have Micochip's mini demo board http://www.microchip.com/stellent/id...cName=en540669 going. But the 67J50 is elusive for me. Not ruling out my own operator error here, but this operator is running out of ideas ..

  18. #18
    Join Date
    Sep 2009
    Posts
    737

    Default Re: HID USB on 18F87J50

    Darrel, thank for support.
    I have 3.3V om Vusb... That was first thing to check...
    I can send you PIC. Just give me adress.

  19. #19
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    Thanks Pedja,

    We have some of those chips, but no boards to put it on.
    At least none that would be easy to use.

    I think the 67J50 should be good enough since it's in the same family as the 87J50.
    We shall see this weekend.
    DT

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

    Default Re: HID USB on 18F87J50

    I found this on page 81: But I guess you found that already.
    Note: Addresses, F40h through F5Fh, are not
    part of the Access Bank, therefore specifying
    a BSR should be used to access these
    registers.
    See, its a feature, not a bug!
    Last edited by ScaleRobotics; - 21st August 2011 at 22:03.

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

    Default Re: HID USB on 18F87J50

    Steve

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

  22. #22
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    Quote Originally Posted by scalerobotics View Post
    I found this on page 81: But I guess you found that already.
    See, its a feature, not a bug!
    I tried to head off that question in my earlier post.
    I understand that it's outside of the access bank, but that only affects the "banked" opcodes (movf, movwf, bcf, bsf, iorwf etc). Banked opcodes are the only ones that work in that range on the 67J50.

    MOVFF and indirect addressing are not affected by the BSR register.
    They use the full address of the register.

    From the MOVFF Instruction definition ...
    Location of source ‘fs’ can be anywhere
    in the 4096-byte data space (000h to
    FFFh) and location of destination ‘fd’
    can also be anywhere from 000h to
    FFFh.
    DT

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

    Default Re: HID USB on 18F87J50

    I think it is sort of interesting that in both the PIC18F47J53, and the PIC18F46J50 (both known to work with PBP USB) it states:
    Note: The SFRs located between EB0h and
    F5Fh are not part of the Access Bank.
    Either BANKED instructions (using BSR) or
    the MOVFF instruction
    should be used to
    access these locations. When programming
    in MPLAB® C18, the compiler will
    automatically use the appropriate
    addressing mode.
    However, for the PIC18F67J50, they leave the MOVFF part out of this statement. I wonder if Microchip knows its errata and just didn't add it to the errata list. Or it's just a coincidence.
    Last edited by ScaleRobotics; - 22nd August 2011 at 03:02.

  24. #24
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    Hmmmm, very interesting indeed.
    DT

  25. #25
    Join Date
    Sep 2009
    Posts
    737

    Default Re: HID USB on 18F87J50

    I was out of town, now I'm reading posts, and i tested hardware with HID boot loader, and it works.
    When can I expect solution?
    Is this will be corrected in PBP2.60(which I currently use), or I must upgrade to PBP3?
    I really appreciate your efforts.
    Thanks to all

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

    Default Re: HID USB on 18F87J50

    There's no good reason to not upgrade to PBP3... forum is free... now say to Melabs & Crownhill you appreciate the forum because it saved your butt a couple of times... get the upgrade
    Steve

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

  27. #27
    Join Date
    Sep 2009
    Posts
    737

    Default Re: HID USB on 18F87J50

    Yes, you're right, I'll get update

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

    Default Re: HID USB on 18F87J50

    I didn't get very far on the Microchip forum. http://www.microchip.com/forums/tm.a...mpage=1#597082 They wanted me to try the simulator, and see if the simulator thought that should work or not. I couldn't get far enough in Mplab to find out. Though I am not sure how useful that would be. Does a simulator always sim what it should?

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

    Default Re: HID USB on 18F87J50

    MPSIM worked with PBP 2.x, will try with PBP3. It has to.

    And NO a simulator do not always give you the good results, some are worst than others. As a guideline they are usually decent tool or pure toy, not much.
    Steve

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

  30. #30
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    What did you try in MPSIM?

    I'm finding that it's reversed in MPSIM.
    MOVFF and FSR's work, but banked instructions don't.
    DT

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

    Default Re: HID USB on 18F87J50

    I haven't tried this specific PIC yet. I try to stay away of Sims
    Steve

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

  32. #32
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB on 18F87J50

    OK, I'm getting closer.
    I think I can make USB work on it.

    What a screwy chip.
    DT

Members who have read this thread : 1

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