Use your forum account to login.


TOP Contributors

  1. MikroElektronika Team (743 codes)
  2. Shawon Shahryiar (262 codes)
  3. Alcides Ramos Zambrano (170 codes)
  4. S P (67 codes)
  5. Dany (66 codes)
  6. MikroBUS.NET Team (35 codes)
  7. NART SCHINACKOW (34 codes)
  8. Armstrong Subero (26 codes)
  9. Roman Toropov (26 codes)
  10. FOURNET Olivier (25 codes)

Most Downloaded

  1. Timer Calculator (95183 times)
  2. FAT32 Library (49992 times)
  3. Network Ethernet Library (44886 times)
  4. USB Device Library (34991 times)
  5. Network WiFi Library (32186 times)
  6. FT800 Library (28012 times)
  7. GSM click (21755 times)
  8. PID Library (21578 times)
  9. microSD click - Example (17762 times)
  10. GSM 2 click (14777 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back




Author: Dany

Last Updated: 2019-04-13

Category: USB

Downloaded: 4939 times

Followed by: 3 users

USB libraries, new architecture. Permits composite USB devices (possibilities: HID, CDC and MSD).
-- for P18's or P24's with USB --

Version 1.1: Modified so that (changes to) values in "UsbProjectItems" like PID and VID are actually visible in the executable.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "USB_NA" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "USB_NA" changes.

Do you want to report abuse regarding "USB_NA".

  • Information
  • Comments (5)

Library Blog

This library is intended to make composite USB devices (max 1 of each type below):

HID: Human Interface devices, e.g. Keyboard, mouse, etc..

CDC: Communication device: e.g. serial port

MSD: mass storage device, e.g. SDMMC card.


Important remarks:CDC devices:

  • - Do not forget to add (if not already there) the VID and the PID of your device to the usbser.inf file (C:\Windows\inf).
    The entry in the usbser.inf file in the Windows directory has to look like:
    %DESCRIPTION%=DriverInstall, USB\VID_1234&PID_2000&MI_00
    where "xx" in "&MI_xx" is the number of the CDC interface.
  • - Every time you install (plug in) a CDC device with a new VID/PID combination, windows will give it a comportnumber that was not used before, so the used number always increases. If you want you can change it to a more acceptable number using the windows 'device manager'. Portnumbers already taken can be found in the registry: See

MSD devices:

  • The library assumes the SDMMC card is always present and writable. Also hot swap is not allowed.
  • The maximum card size supported is 4 GB.


- USB_CDC_Library_NA

- USB_HID_Library_NA

- USB_MSD_Library_NA

- USB_Library_Core_Constants_NA

- USB_Library_Core_NA

- USB_HID_Keyb_Library_NA (Ps2 keyboard to USB keyboard; Supports also the "Sleep", "Wake-up" and "Power" keys.)

The zipfile has the same content as the package.Have Fun!


Version 1.1: Modified so that (changes to) values in "UsbProjectItems" like PID and VID are actually visible in the executable.

Important: the "USBxxx_ProjectItems.mpas" files have been changed!


18-03-2012: Removed an error in "USB_MSD_Library", calculation of the card capacity did not work correctly for cards of exactly 4 GB large. Still, the max size of the card supported here is 4 Gb.

29-03-2012: Added the P24 version of the libraries. No "keyboard" libraries yet however.
Have fun!

2012-06-08: The help section in the package and zip file has been updated.

2012-11-12: The microBasic package(s) ha(s)(ve) been added.

Only the .mcl files are available as "library" files: they are copied from the mikroPascal version (the mP and mB .mcl files are compatible - luckely - ).

If you want to see some sources: look into the mP versions.

The example files are still in mP, not in mB. (I do not have an mB licence, so I can not compile them).

Some of the helpfiles are also still referring to mP, but all library "interfaces" are available in the mB language.

2013-01-26:  Replaced "Delay_ms" and "Delay_us" by routines available in the Delays lib.
"Delay_ms" and "Delay_us" are inline routines and cannot be used in libraries if they are to be used without source (e.g. non Pascal compilers).


2014-03-13: The mikroBasic files and zip files have been updated. All mB sources are present now (not tested if compilable though).


2014-03-26: Corrected an error in the Delphi unit "Wincom.pas" (used in the windows application TestCDC). Thanks to Virgil Chindris for pointing out type errors in the routines "getChar" and "OpenCom".


2014-05-02: CDC library: Removed automatic sending of a zero length packet after sending a 64 bytes packet (slowed down sending  from PIC to PC).

2015-01-26: Replaced the mB files: all mB files are compilable now (which e.g. means that all "with" statements are dealt with). I could however not link and test the libraries (no mB licence).

2019-04-12:  Removed a blocking statement in 'InitUsb'. The SW was blocked in case no USB connection was made.


Tool: Timer-Prescaler


Tool (excel workbook) to help with the choice of the prescaler and settings of a timer. For PIC16/18, PIC24, dsPIC33 and PIC32.

[Learn More]



RC6 and RC6 (Philips IR remote control system) decoders, decodes the Rc5/6 toggle, Rc5/6 System and Rc5/6 command. For the moment only RC6 "mode 0" (most used) can be decoded. Made for 36 Khz IR receivers with inverse output (= output active low), like the TSOP1736. -- for P16F627A, 628A, 648A --

[Learn More]



Library for a 4x4 keypad connected to the PIC via an PCF8574 I2c expander (Two I2c lines in stead of 8 I/O pins). This saves a lot of PIC I/O pins. Permits also small PIC's (with low pin count) to control a keypad.

[Learn More]