ME Labs, Inc.
719-520-5323
 
Home:
  Developer Resources:

Programming Clues
    Sample Programs
   
    PICBASIC PRO™
Compiler Manual
    PICBASIC™ Compiler
Manual
    Serin2/Serout2 Modes
    ASCII Character Set
    Number Conversion
    Floating Point
Routines
    PBP Debug Monitor
    Articles and Tutorials

Hardware Clues
    Parts / Vendor List
    PICPROTO™ Boards
    LAB-X1 Docs
    LAB-X2 Docs
    LAB-X20 Docs
    LAB-X3 Docs
    LAB-X4 Docs
    LAB-XUSB Docs
    LAB-XT Docs
     
 

ME Labs, Inc. | 1-719-520-5323 | Example Program - USBJADEM.pbp

PICBASIC PRO USB sample program implements the functionality of the Jan Axelson demo which accepts two numbers from the host, increments each and sends them back. An application running on the host sends the numbers and displays the returned values. Compilation of this program requires that specific support files be available in the source directory. You may also need to modify the file USBDESC.ASM so that the proper descriptor files are included. For detailed information, see the file PBP\USB18\USB.TXT.
01' Name        : USBJADEM.pbp
02' Compiler    : PICBASIC PRO Compiler 2.6
03' Assembler   : MPASM
04' Target PIC  : PIC18F4550 or similar type
05' Hardware    : LAB-XUSB Experimenter Board
06' Oscillator  : 20MHz external
07' Keywords    : USBSERVICE, USBINIT, USBIN, USBOUT
08' Description : PICBASIC PRO USB sample program implements the
09' functionality of the Jan Axelson demo which accepts two numbers
10' from the host, increments each and sends them back. An application
11' running on the host sends the numbers and displays the returned values.
12' Compilation of this program requires that specific support files be
13' available in the source directory.  You may also need to modify the
14' file USBDESC.ASM so that the proper descriptor files are included. For
15' detailed information, see the file PBP\USB18\USB.TXT.
16'
17 
18Define OSC 48
19 
20Include "ja_desc.bas"   ' Include the HID descriptors
21     
22buffer Var Byte[8]
23cnt    Var Byte
24 
25   USBInit
26 
27' Wait for USB input of 2 numbers.
28idleloop:
29   USBService           ' Must service USB regularly
30   cnt = 8              ' Specify input buffer size
31   USBIn 1, buffer, cnt, idleloop
32 
33' Message received.  Increment the bytes and send them back.
34   buffer[0] = buffer[0] + 1
35   buffer[1] = buffer[1] + 1
36 
37outloop:
38   USBService            ' Must service USB regularly
39   USBOut 1, buffer, 2, outloop ' Send the bytes back
40   Goto idleloop         ' Wait for next buffer
41 
42   End

Download the program file.