Easy HID Command -Response application


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    May 2005
    Location
    Ne ohio
    Posts
    21

    Default

    Thanks,
    I'll try your code out. though I'm at Rev. 2.5 I just ordered an upgrade to the Latest PBPro.
    I generated a Feature report using HIDMaker with a 64byte array (similar to what I've been using all along) and I'm getting about 21 msecs on this PC for each pass through the "Timer1_Tic" Handler. This is nearly stock HIDMaker C# and PBasic Code except I've added a Stopwatch from System.Diagnostics to capture the milliseconds to execute the SendReports then ReadReports.

    Elsewhere in my older code from EasyHID, I've moved the USBSERVICE inside my timer interrupt routine and that has improved the time to return input reports. So now I currently USBSERVICE at about 1 msec. intervals.

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

    Default

    The service routine should work with 2.50.

    I've had it all working while embedded into various other programs from 2.47 to 2.60. This time I just put it all in an include file that's specific to your situation. Well, a lot of peoples situations.

    You should be aware that USB is handled differently in PBP 2.60.
    Programs from earlier versions will have to be modified to work with it.

    And since your program is coming from HIDmaker, you'll probably need an upgrade if you've had it awhile. I don't know that for sure because I don't use it, but it only seems logical.

    DT

  3. #3

    Default

    Where should this go?

    I cut'n'pasted from the above code section, into microcodestudio, then added this to the top, before the define

    Code:
    ' **************************** Added from other demo
    buffer	Var	Byte[16]
    cnt	Var	Byte
    LED	Var	PORTB.0
    Define  OSC 48
    '****************************************************
    
    high led


    Then at the bottom after overusbservice I added the usb in/out and a led flash to show its alive

    Code:
    idleloop:
    
        low led
        pause 500
        high led
        pause 500
    
    	cnt = 16	' Specify input buffer size
    	USBIn 3, buffer, cnt, idleloop
    
    ' Message received
    
    	buffer[0] = "H"
    	buffer[1] = "e"
    	buffer[2] = "l"
    	buffer[3] = "l"
    	buffer[4] = "o"
    	buffer[5] = " "
    	buffer[6] = "W"
    	buffer[7] = "o"
    	buffer[8] = "r"
    	buffer[9] = "l"
    	buffer[10] = "d"
    	buffer[11] = 13
    	buffer[12] = 10
    	buffer[13] = 0
    
    outloop:
    	
        USBOut 3, buffer, 14, outloop
    
    	Goto idleloop	' Wait for next buffer
    usbinit and usbservice was removed from the code of the other demo like it says to.

    It looks to me like a worker, but i get compile errors, lots of them

    This one

    Code:
    IDLEIF             VAR UIR.4         ; USB Idle Interrupt Flag
    <
    gives me a bad datatype (first of a few)

    and this one

    Code:
        UIE = $7F                    ; enable USB interrupts
    throws up a syntax error with some more below it


    I tried it as

    INCLUDE "USB_ASM_Service"

    At the top of my little test and MCS opened it as a 2nd page, and threw up the same errors.

    Just for completeness thats here
    Code:
    include "USB_ASM_Service.pbp"
    
    ' **************************** Added from other demo
    buffer	Var	Byte[16]
    cnt	Var	Byte
    LED	Var	PORTB.0
    Define  OSC 48
    ' ****************************************************
    
    high led
    
    idleloop:
    
        low led
        pause 500
        high led
        pause 500
    
    	cnt = 16	' Specify input buffer size
    	USBIn 3, buffer, cnt, idleloop
    
    ' Message received
    
    	buffer[0] = "H"
    	buffer[1] = "e"
    	buffer[2] = "l"
    	buffer[3] = "l"
    	buffer[4] = "o"
    	buffer[5] = " "
    	buffer[6] = "W"
    	buffer[7] = "o"
    	buffer[8] = "r"
    	buffer[9] = "l"
    	buffer[10] = "d"
    	buffer[11] = 13
    	buffer[12] = 10
    	buffer[13] = 0
    
    outloop:
    	
        USBOut 3, buffer, 14, outloop
    
    	Goto idleloop	' Wait for next buffer
    Last edited by f_lez; - 1st November 2009 at 17:05.

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

    Default

    Looks like you've been busy while I was sleeping.

    PBP 2.46 was missing a few registers in the PIC18EXT.bas file.
    You can either add these lines to that file, or place them at the top of your program (before the INCLUDE file).
    Code:
    UIR  VAR BYTE EXT
    UIE  VAR BYTE EXT
    UEIE VAR BYTE EXT
    UEIR VAR BYTE EXT
    For the _config depricated warning you can add w = -230 to the 18F2550.inc file ...
    Code:
            LIST p = 18F2550, r = dec, w = -311, w = -230, f = inhx32
    hth,
    DT

  5. #5

    Default

    thanks that was just the little gem of info i was missing!

    And it works!

  6. #6

    Default

    Simple code in a loop...

    Code:
    ' Main Program Loop
    Loop:
     
        USBOut 3, Buffer, Cnt, loopy
    loopy:
        porta=170 ' fancy led pattern0
        pause 500
        porta=85  ' fancy led pattern1
        pause 500
    
        goto loop
    end
    After about 30 minutes, stops running......

    Pic is stable etc had it running 24hrs+ on a simple led flasher. (on same dev board)

    any guesses?
    Last edited by f_lez; - 28th February 2010 at 19:54.

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

    Default

    Well, it's a Total guess but ...

    Try adding a USBIN statement to the loop.
    If anything comes in, and the SIE doesn't get released, everything locks up (including the PC application).

    The reason I say it's a guess is because it requires recieved data.
    If you are using HyperTerminal then you would need to type something to have it happen.

    DT

Similar Threads

  1. USB hid maker help please.
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd April 2013, 15:49
  2. i cant get 18f2550 work as HID
    By Ahmadabuomar in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 13th October 2009, 17:39
  3. Unusual Interrupts Application Problem
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th May 2009, 12:55
  4. Hid Maker FS Problems
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th April 2009, 22:27
  5. Making your own HID descriptor file
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th April 2005, 13:35

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