The USB microcontroller program consists of three parts :

1. Initialize the microcontroller and peripheral circuits (including USB chips)

2, the main loop part, used to detect

3. Interrupt service program whose task is time sensitive and must be executed immediately

According to the USB protocol, any transmission is started by the host host. In this way, the MCU works as its foreground and waits for an interrupt. The host first sends a token packet to the USB device (here, PDIUSBD12). After receiving the token packet, the PDIUSBD12 receives the token packet. To the microcontroller to send an interrupt, the microcontroller enters the interrupt service routine, first read the interrupt register of PDIUSBD12, determine the type of USB token packet, and then perform the corresponding operation.

Note: Therefore, the USB microcontroller program is mainly the preparation of the interrupt service program. In the USB microcontroller program, the response to various token packets should be completed. The more difficult to handle is the SETUP package, which is mainly the programming of port 0.
The communication between the MCU and PDIUSBD12 is mainly realized by the MCU sending commands and data to PDIUSBD12. The command words of PDIUSBD12 are divided into three types: initialization command word, data stream command word and general command word. PDIUSBD12 gives the code and address of various commands. The MCU first sends a command to the command address of PDIUSBD12, and then sends or reads different data according to the requirements of different commands. Therefore, each command can be made into a function, each function can be implemented by a function, and the function can be directly called later.

USB initialization program

The USB initialization process is

Set Address Enable;

Set Endpoint Enable (the LED is lit at this time);

Disconnect;

Delay (1~2 s);

Connect (ie, call Set Mode with the 43h parameter, then the LED is off);

Read Interrupt Register.

Floor Display

Floor Display,Floor-Standing Lcd Display,Floor Standing Pop Up Display,Floor Advertising Screen Display

Kindwin Technology (H.K.) Limited , https://www.szktlled.com

Posted on