Mikroelektronika Usb Hid Terminal

Do I need to change the default values of VID and PID in the mikroElektronika USB(HID) Terminal when creating. USB Device Not Recognized using PIC18F4550. USB Library contains HID routines that support HID class devices. 2002-2012 mikroElektronika. Mikroelektronika Usb Hid Terminal Download. PIC18F4550 Communication with PC using USB HID Class, Visual Basic Communication xpress USB HID Terminal is a compact tool designed to make use of the HID class in order to test the communication to a USB. MikroElektronika - USB Device Library (HID. Of how to create your own USB HID TouchPad and a. And example HID terminal communicaion.

USB Library

Universal Serial Bus (USB) provides a serial bus standard for connecting a wide variety of devices, including computers, cell phones, game consoles, PDA’s, etc.

USB Library contains HID routines that support HID class devices, and also the generic routines that can be used with vendor specified drivers.

USBHID Class

The HID class consists primarily of devices that are used by humans to control the operation of computer systems. Typical examples of HID class devices include :

  • Keyboards and pointing devices, for example: standard mouse devices, trackballs, and joysticks.
  • Front-panel controls, for example: knobs, switches, buttons, and sliders.
  • Controls that might be found on devices such as telephones, VCR remote controls, games or simulation devices, for example: data gloves, throttles, steering wheels, and rudder pedals.
  • Devices that may not require human interaction but provide data in a similar format to HID class devices, for example, bar-code readers, thermometers, or voltmeters.

Many typical HID class devices include indicators, specialized displays, audio feedback, and force or tactile feedback. Therefore, the HID class definition includes support for various types of output directed to the end user.

Descriptor File

Each project based on the USB library should include a descriptor source file which contains vendor id and name, product id and name, report length, and other relevant information. To create a descriptor file, use the integrated USBHID terminal of mikroC PRO for PIC (Tools › USB HID Terminal). The default name for descriptor file is USBdsc.c, but you may rename it.

Important :
  • The USB library routines have been changed. Please, have this in mind when migrating projects from previous versions of the compiler.
  • Also, this relates to the descriptor source file, so it is necessary to create a new descriptor file in order to make your project work.

Library Routines

HID_Enable

Prototype

void HID_Enable(char *readbuff, char *writebuff);

Description

Enables USBHID communication.

Parameters
  • readbuff: Read Buffer.
  • writebuff: Write Buffer.

These parameters are used for HID communication.

Returns

Nothing.

Requires

Nothing.

Example
Notes

This function needs to be called before using other routines of USBHID Library.

HID_Read

Prototype

char HID_Read(void);

Description

Receives message from host and stores it in the Read Buffer.

Parameters

None.

Returns

If the data reading has failed, the function returns 0. Otherwise, it returns number of characters received from the host.

Requires

USBHID needs to be enabled before using this function. See HID_Enable.

Example
Notes

None.

HID_Write

Prototype

char HID_Write(char *writebuff, char len);

Description

Function sends data from Write Buffer writebuff to host.

Parameters
  • writebuff: Write Buffer, same parameter as used in initialization; see HID_Enable.
  • len: specifies a length of the data to be transmitted.
Returns

If the data transmitting has failed, the function returns 0. Otherwise, it returns number of transmitted bytes.

Requires

USBHID needs to be enabled before using this function. See HID_Enable.

Example
Notes

Function call needs to be repeated as long as data is not successfuly sent.

HID_Disable

Prototype

void HID_Disable(void);

Description

Disables USBHID communication.

Parameters

None.

Returns

Nothing.

Requires

USBHID needs to be enabled before using this function. See HID_Enable.

Example
Notes

None.

USB_Interrupt_Proc

Usb
Prototype

void USB_Interrupt_Proc(void);

Description

This routine is used for servicing various USB bus events. Should be called inside USB interrupt routine.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
Notes

Do not use this function with USB_Polling_Proc, only one should be used. To enable servicing through interrupt, USB_INTERRUPT constant should be set (it is set by default in descriptor file).

USB_Polling_Proc

Prototype

void USB_Polling_Proc(void);

Description

This routine is used for servicing various USB bus events. It should be periodically, preferably every 100 microseconds.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
Notes

Do not use this functions with USB_Interrupt_Proc. To enable servicing by polling, USB_INTERRUPT constant should be set to 0 (it is located in descriptor file).

Gen_Enable

Prototype

void Gen_Enable(char* readbuff, char* writebuff);

Description

Initialize the USB module of the MCU.

Parameters
  • readbuff: Read Buffer.
  • writebuff: Write Buffer.
Returns

Nothing.

Requires

USB needs to be enabled before using this function. See Gen_Enable.

Example
Notes

None.

Gen_Read

Mikroelektronika Usb Hid Terminal
Prototype

char Gen_Read(char *readbuff, char length, char ep);

Description

Generic routine that receives the specified data from the specified endpoint.

Parameters
  • readbuff: Received data.
  • length: The length of the data that you wish to receive.
  • ep: Endpoint number you want to receive the data into.
Returns

Returns the number of received bytes, otherwise 0.

Requires

USB needs to be enabled before using this function. See Gen_Enable.

Example
Notes

None.

Gen_Write

Prototype

char Gen_Write(char* writebuff, char length, char ep);

Description

Sends the specified data to the specified endpoint.

Parameters
  • writebuff: The data that you want to send.
  • length: the length of the data that you wish to send.
  • ep: Endpoint number you want to send the data into.
Returns

Returns the number of transmitted bytes, otherwise 0.

Requires

USB needs to be enabled before using this function. See Gen_Enable.

Example
Notes

None.

Library Example

This example establishes connection with the HID terminal that is active on the PC. Upon connection establishment, the HID Device Name will appear in the respective window. After that software will wait for data and it will return received data back. Examples uses USBdsc.c descriptor file, which is in the same folder, and can be created by the HID Terminal.

Usb Cdc

HW Connection

USB connection scheme

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!

Integrated Tools

Active Comments Editor

Active Comments Editor is a tool, particularly useful when working with Lcd display. You can launch it from the drop-down menu Tools › Active Comments Editor or by clicking the Active Comment Editor Icon from Tools toolbar.

ASCII Chart

The ASCII Chart is a handy tool, particularly useful when working with Lcd display. You can launch it from the drop-down menu Tools › ASCII chart or by clicking the View ASCII Chart Icon from Tools toolbar.

EEPROM Editor

The EEPROM Editor is used for manipulating MCU's EEPROM memory. You can launch it from the drop-down menu Tools › EEPROM Editor.

When you run mikroElektronika programmer software from mikroC PRO for PIC IDE - project_name.hex file will be loaded automatically while ihex file must be loaded manually.

GLCD Bitmap Editor

The mikroC PRO for PIC includes the Graphic Lcd Bitmap Editor. Output is the mikroC PRO for PIC compatible code. You can launch it from the drop-down menu Tools › Glcd Bitmap Editor.

HID Terminal

The mikroC PRO for PIC includes the HID communication terminal for USB communication. You can launch it from the drop-down menu Tools › HID Terminal.

Lcd Custom Character Editor

mikroC PRO for PIC includes the Lcd Custom Character Editor. Output is mikroC PRO for PIC compatible code. You can launch it from the drop-down menu Tools › Lcd Custom Character.

mikroBootloader

What is a Bootloader

Usb Hid Device

(From Microchip’s document AN732) The PIC16F87X family of microcontrollers has the ability to write to their own program memory. This feature allows a small bootloader program to receive and write new firmware into memory. In its most simple form, the bootloader starts the user code running, unless it finds that new firmware should be downloaded. If there is new firmware to be downloaded, it gets the data and writes it into program memory. There are many variations and additional features that can be added to improve reliability and simplify the use of the bootloader.

Note : mikroBootloader can be used only with MCUs that support flash write.

How to use mikroBootloader

  1. Load the MCU with the appropriate hex file using the conventional programming techniques.
  2. Start mikroBootloader from the drop-down menu Tools › Bootoader.
  3. Click on Change Settings and select the COM port and the BAUD that will be used.
  4. Click on Connect and wait until connected. Since the bootcode in the MCU only gives the computer 4-5 sec to connect, you should reset the MCU and then click on the Connect button within 4-5 seconds.
  5. Click on Browse for HEX and select the HEX file you would like to upload.
  6. The last line in then history window should now read “Connected”.
  7. To start the upload, just click on the Begin uploading button.
  8. Your program will written to the MCU. Bootloader will report an errors that may occur.
  9. Reset your MCU and start to execute.

Usb Hid Driver

Features

Usb Keyboard Emulation

The boot code gives the computer 5 seconds to get connected to it. If not, it starts running the existing user code. If there is a new user code to be downloaded, the boot code receives and writes the data into program memory.

The more common features a bootloader may have are listed below:

  • Code at the Reset location.
  • Code elsewhere in a small area of memory.
  • Checks to see if the user wants new user code to be loaded.
  • Starts execution of the user code if no new user code is to be loaded.
  • Receives new user code via a communication channel if code is to be loaded.
  • Programs the new user code into memory.

Integrating User Code and Boot Code

The boot code almost always uses the Reset location and some additional program memory. It is a simple piece of code that does not need to use interrupts; therefore, the user code can use the normal interrupt vector at 0x0004. The boot code must avoid using the interrupt vector, so it should have a program branch in the address range 0x0000 to 0x0003. The boot code must be programmed into memory using conventional programming techniques, and the configuration bits must be programmed at this time. The boot code is unable to access the configuration bits, since they are not mapped into the program memory space.

Seven Segment Editor

The Seven Segment Editor is a convenient visual panel which returns decimal/hex value for any viable combination you would like to display on seven segment display. Click on the parts of seven segment image to get the requested value in the edit boxes. You can launch it from the drop-down menu Tools › Seven Segment Editor or by clicking the Seven Segment Editor Icon from Tools toolbar.

UDP Terminal

The mikroC PRO for PIC includes the UDP Terminal. You can launch it from the drop-down menu Tools › UDP Terminal.

USART Terminal

The mikroC PRO for PIC includes the USART communication terminal for RS232 communication. You can launch it from the drop-down menu Tools › USART Terminal or by clicking the USART Terminal Icon from Tools toolbar.

Mikroelektronika Usb Hid Terminal

USB HID Bootloader

Mikroc Usb Hid Terminal

Mikroelektronika Usb Hid Terminal

The mikroC PRO for PIC includes the USB HID bootloader application for PIC18 family of MCUs that feature internal USB HID module. You can launch it from the drop-down menu Tools › USB HID Terminal.

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!