Menu ▾ ▴

GCBASIC USB: WinUSB with No Driver to Install

Anobium
3 days ago
2 days ago
  • Anobium

    Anobium - 3 days ago

    GCBASIC USB demonstration: WinUSB with no driver to install

    I have updated the the LibK/WinUSB demonstrations (USB_LIBKWINUSB_18F14K50_Demonstration.gcb), so that Windows needs no driver for it. The version that was published required a driver and was not easy to install.

    With this change, a USB GCBASIC device now answers Windows' Microsoft OS 1.0 descriptor requests ("WCID"), so Windows 8.1 and later load their own WinUSB driver when the board is plugged in. The protocol has not changed: the PC program sends the same vendor requests (LEDs on and off, LED state, port status, keep-alive), so, the demo application is just the same.

    Files

    File What it is
    USB_WINUSB_<chip>_Demonstration.gcb The solution, one source per board: 18F14K50, 16F1454, 16F1455, 16F1459, 18F45K50, 18F4550, and the Starter Kit (18F46J50). Compile it with GCBASIC as usual (F6 in GCcode).
    usb.h GCBASIC's own include\usb.h (2026-10-19): it has USB_WCID and the PIC18 bank fix, so the programs use #include <usb.h>; there is no local copy any more.
    PC_Application\ The Windows program (VB.NET, LibUsbDotNet). It now looks for 04D8:0052.

    The boards

    Every board I have tested uses the same hardware, USB ID and GUID: the requests 130 to 138 (red, yellow and green LEDs), 140 (the four inputs) and 255 (keep-alive). Only the chip, its clock and its pins differ.

    Board Clock LEDs I/O 1 to 4 (keep-alive, red, yellow, green) Inputs I/O 5 to 8 Switches (PC app)
    18F14K50 12 MHz crystal, PLL RC0, RC1, RC2, RC3 RB4, RA3, RA4, RA5 1 (I/O 6)
    16F1459 internal, PLL, active clock tuning RC0, RC1, RC2, RC3 RB4, RA4, RA3, RA5 1 (I/O 6 = RA4)
    16F1454 / 16F1455 internal, PLL, active clock tuning RC0, RC1, RC2, RC3 RC4, RA4, RA3, RA5 1 (I/O 6 = RA4)
    18F45K50 internal, PLL, active clock tuning RA4, RA5, RC0, RC1 RB4, RB5, RB6, RB7 4
    18F4550 20 MHz crystal, PLL (PLLDIV 5) RA4, RA5, RC0, RC1 RB4, RB5, RB6, RB7 4
    18F46J50 (PIC18F Starter Kit 1) 12 MHz crystal, PLL drawn on the OLED (GCBASIC GLCD library) I/O 6 = MENU (RB0); 5, 7, 8 read 1 1 (I/O 6)
    • The 16F145x boards match the 16F1459: LEDs on RC0 to RC3, one switch on RA4 (I/O 6). The 16F1459 is pin-compatible with the 18F14K50 (the same LEDs; I/O 6 on RA4, I/O 7 on RA3). The 14-pin 16F1454/1455 have no PORTB, so their I/O 5 is RC4.
    • The old LibK versions (16F145x: two LEDs and ADC values on requests 130 to 136; the 18F45K50 GCBlib demo: an I2C LCD and requests 100 to 105) are replaced. The originals are still in Demonstration_Sources.git.
    • The PC app finds the number of switches in its BoardSwitches table, from the chip in the board's USB product name.
    • The Starter Kit program is standalone (no #option bootloader): the kit has no user LEDs, so the four LEDs are circles on the OLED (filled when on), with the USB state and the MENU button. It also builds for the 18F47J53 (the kit's pinout) with only its #chip line changed: 4,536 words, 1,918 bytes. There is no 18F47J50.

    In the program

    #define USB_VID 0x04D8
    #define USB_PID 0x0052
    #define USB_REV 0x0100
    #define USB_WCID
    #define USB_WCID_GUID "{BFC2B144-FB5A-4F56-98AC-93BC164EED46}"
    #include <usb.h>
    
    • USB_WCID adds three answers: the OS string (string index 0xEE, "MSFT100" and the vendor code), the Extended Compat ID ("WINUSB") and the Extended Properties (DeviceInterfaceGUIDs).
    • USB_WCID_GUID is required with USB_WCID. It must be 38 characters, and each solution needs its own.
    • USB_WCID_VENDOR_CODE is the request code Windows uses to read the descriptors. It defaults to 0x20; it must not be one of the program's own request codes.
    • Without USB_WCID, usb.h builds as previous USB solution: the 15 Demonstration_Sources demos that use it give the same code, plus one clrf BSR at the start of the USB interrupt on PIC18 (the bank fix). Only the build-time strings differ.

    The USB ID

    • 04D8 is Microchip's vendor ID for this type of solution.
    • The bcdDevice is 0x0100. Windows asks for the OS string only once per VID, PID and bcdDevice, and remembers the answer. A device first seen without WCID is not asked again until the bcdDevice changes, or until the key tion: the LibK driver's INF matches VID_1209&PID_2006.

    Recovery in the PC program provided

    • Unplug: the device notification closes the device, and the screen shows "not connected".
    • Plug in again: the 1 s timer looks for the device and opens it. The LED states are read again.
    • A failed transfer or a wrong keep-alive (every 10 s): the device is closed and found again (CloseDevice). Before this change, transfer errors were ignored, and an empty keep-alive reply could throw.

    Tested

    Board Status (2026-10-19)
    18F14K50 Tested on the board: works (enumerates with WinUSB and no driver; the PC app connects, reads the LEDs and I/O 6)
    16F1454 Tested on the board
    16F1455 Tested on the board
    16F1459 Tested on the board
    18F45K50 Not tested yet (the pins RA4, RA5, RC0, RC1 and RB4-RB7 are not yet checked on a board)
    18F46J50 (Starter Kit) Not tested yet (standalone: program it with a PICkit; it replaces the bootloader)
    18F4550 Not tested yet (20 MHz crystal; the pins RA4, RA5, RC0, RC1 and RB4-RB7 are not yet checked on a board)

    To test a board:

    1. Program its HEX (in USB_WINUSB_<chip>_Demonstration.build\).
    2. Plug it in. Device Manager should show it under "Universal Serial Bus devices", with WinUSB and no driver installed.
    3. Start PC_Application\VBProject\bin\Release\USB_LIBKWINUSB_DEMO_PROGRAM.exe. Check the LEDs, the port status and the keep-alive LED.
    4. Unplug the board and plug it in again: the program should connect again.

    The PC program was built with Visual Studio 2017's MSBuild (the project uses VB 14 syntax). Started with no board, it runs and keeps looking for the device.

    Enjoy

     
  • HackInBlack

    HackInBlack - 3 days ago

    it's found here:-
    USB_Solutions/GreatCowBASIC_Solutions/LIBWINUSB_Solutions/USB GCBlib demos 14k50.gcb
    Good_Stuff! i think i'll be blowing the dust off some '1454 chips very soon...80)

     
  • Anobium

    Anobium - 3 days ago

    I will post new demos today. You will need a new usb.h

     
  • HackInBlack

    HackInBlack - 3 days ago

    i have a Microchip PICDEM FS USB demo board here (c.2012) 18F45K50, running the original MLA demo's, powered from a PICkit2; what files will i need to use the GCBasic updated versions?

     

    Last edit: HackInBlack 3 days ago
    • Anobium

      Anobium - 3 days ago

      Got a photo of the board?

       
  • HackInBlack

    HackInBlack - 3 days ago

    this one

     
    • Anobium

      Anobium - 3 days ago

      That will run the CDC and WINUSB solution very nicely.

      I have two of them hooked up to my Home Assistant Server and the report and control the temperature.

       
  • Anobium

    Anobium - 3 days ago

    See attached.

     
  • HackInBlack

    HackInBlack - 3 days ago

    i can't get the GCB demo program for 18F45K50 to compile:-

     
    • Anobium

      Anobium - 3 days ago

      What this URL to the demo ? You may need more supporting pieces. I do not know without the URL.

       
  • Anobium

    Anobium - 3 days ago

    Those will not compile without build 1660. I cannot get that out till Thursday. I have other things to do. :-)

    The build you have is missing 14-20 new libraries.

     
  • HackInBlack

    HackInBlack - 3 days ago

    fairy nuff! i'm jumping the gun again...80)

     
  • Anobium

    Anobium - 2 days ago

    You will also need to new application and dll for the WinUSB support. The application looks the sams but is now using WinUSB.

    Once you have the demo working you can develop your own solution using the demo GCB and the application source. If you do not want to use VS for development of the application then use the source as an information resource.

    I hope this work for you.

     
  • HackInBlack

    HackInBlack - 2 days ago

    It LIVES!
    on my board (PICDEM FS USB 2012) I/O.5 is 'S2', I/O.6 is 'S3'

     
    • Anobium

      Anobium - 2 days ago

      Was that a lot easier ? Once we had you on the right library ....so easy!

      And, many times better than the Microchip stack.


      This mine hooked up to Home Assistant!

       
  • HackInBlack

    HackInBlack - 2 days ago

    more details for the file

     

    Last edit: HackInBlack 2 days ago
    • Anobium

      Anobium - 2 days ago

      Please send me these documents, the GCB source and did you update the Windows application?

       

Log in to post a comment.