1/3/2023 0 Comments Card shark kortlekarA PIC18F4550 microcontroller is interfaced to a PC through a USB cable. 430 Chapter 8 Figure 8.9: PIC18F4550 USB interface PROJECT 8.1-USB-Based Microcontroller Output Port This project describes the design of a USB-based microcontroller output port. The microcontroller receives power from the USB port. In addition to the power supply and ground pins, it requires just two pins to be connected to the USB connector. As the figure shows, the interface is very simple. The USB interface of a PIC18F4550 microcontroller is shown in Figure 8.9. Hid_Disable: This function disables the USB data transfer. The name of the buffer (the same buffer used in the initialization) and the length of the data to be sent must be specified as arguments to the function. Hid_Write: This function sends data from the write-buffer to the USB bus. It has no arguments but returns the number of characters received. Hid_Read: This function receives data from the USB bus and stores it in the receive-buffer. It must be called before any other functions of the USB library, and it returns no data. The mikroC language supports the following USB bus library functions when a PIC microcontroller with built-in USB is used (e.g., PIC18F4550), and port pins RC4 and RC5 are connected to the D+ and D pins of the USB connector respectively: Hid_Enable: This function enables USB communication and requires two arguments: the read-buffer address and the write-buffer address. The USBdsc.c file must be included in USB-based projects either via the mikroC IDE tool, or as an include option in the program source file. The default name for descriptor file is USBdsc.c, but it can be renamed if required. To create a descriptor source file we can use mikroCs integrated USB HID terminal tool (see Tools ! HID Terminal). 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. 8.6 mikroC Language USB Bus Library Functions The mikroC language supports a number of functions for USB HID-type communications.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |