Introduction:
The design of USB low-speed devices has reached considerable maturity. Various IC companies have launched USB DEVICE-side solutions, generally using 8 BIT CPU CORE + USB SIE as the mainstream architecture. SH69P04 is a 4BIT OTP microcontroller designed by Sinowealth to enrich USB product applications and reduce USB IC costs. It is used to develop USB DEVICE devices.
SH69P04 functions and features
Figure 1
As shown in Figure 1, SH69P04 integrates USB SIE and supports USB and PS2 port multiplexing. The built-in 1.5K controllable pull-up resistor saves costs for users and can establish stable communication with the PC. I/O port specially designed for MOUSE. The dual CLOCK system makes the IC consume less power and easily meets the USB-IF requirements for SUSPEND current. 8K×16 BIT OTP ROM, convenient for user development. It can support a maximum of 40×8 LCD display or 31 I/Os to meet various user applications. In addition, it also has built-in Watch Dog and Low Power Detect functions.
1. USB and PS2 ports are shared
Switching between USB port and PS2 port through register
PS2PU = 1: If PS2IS = 1, the internal PS2 dedicated pull-up resistor takes effect. When the USB port needs to be used, just set PS2IS = 0 to turn off the PS2 port and its pull-up resistor.
2. 1.5KΩ controllable pull-up resistor
As shown in Figure 2, with this 1.5KΩ controllable pull-up resistor, on the one hand, it can save costs, and on the other hand, it can achieve soft switching to ensure that the PC recognizes DEVICE.
When the USB DEVICE is connected to the PC, the internal 1.5KΩ pull-up resistor is not turned on, so the PC does not think that a new device is connected. Users can safely complete program initialization and other client programs before turning on the pull-up resistor, without having to worry about responding to signals on the USB bus in time. This is because if there is no controllable pull-up resistor but is directly added, then when the DEVICE is connected to the PC, the PC will immediately know that a new device is connected, and will send a signal to the DEVICE after a certain period of time. If the DEVICE continues for several If the communication fails, the PC will think that the DEVICE has an error and will no longer communicate with it.
In addition, combining with Watch Dog can further ensure the connection of DEVICE. Users can calculate the time required for the entire USB initialization process in advance and set up Watch Dog. In the event of a USB initialization error, a Watch Dog Reset will occur, the 1.5KΩ pull-up will be turned off, and the program will restart. The PC will think that the DEVICE has a plug and unplug action. Program deadlocks can also be solved using this method.
Figure 3
3. The I/O port specially designed for MOUSE
is shown in Figure 3. During the principle analysis, Q1.1 and Q1.3 output square waves. In fact, since Photo Transistors use phototransistors, when the grating rotates, the light received by the phototransistors also changes continuously, so the output waveform also changes continuously. And because the grating cannot completely block the light, an OFFSET level will be generated. The actual waveform is shown in Figure 4.
VIH in the figure indicates that once the input level is higher than VIH, the MCU considers it to be a high level. VIL means that once the input level is lower than VIL, the MCU considers it to be a low level. In this state shown in Figure 4, the MCU can easily read the grating rotation. However, due to interference or component aging, the OFFSET level changes, making the input signal level unable to intersect with VIH and VIL (as shown in Figure 5). The MCU will think that the input signal is always high or always low.
SH69P04 provides three levels of pull-down resistors (as shown in Figure 4) for each MOUSE port to control the OFFSET level. The resistance value of the pull-down resistor is selected through the register to solve errors caused by changes in the OFFSET level.
software design
Although the USB protocol is very complex, the programs that need to be written on the MOUSE side are very limited. Users can easily establish contact with the PC. (Windows HID driver is provided by the operating system)
1. USB/PS2 port monitoring
Step 1: Power on, delay 50ms Step 2: Monitor the level of D- within 2ms. If it is high level 4 times, it is the PS2 interface. Otherwise, go to step 3. Step 3: Turn on the USB pull-up resistor, delay500us, and repeatedly monitor the levels of D+ and D- until one of them appears high level. If D+ is high level, it is the PS2 interface. If D- is low, go to step 4. Step 4: Turn off the USB pull-up resistor, delay 100us. If D+/D- are both low level, it is a USB interface.
Otherwise it's the PS2 interface.
2. USB Enumeration Process
The whole process is a bit like taking a test. PC asked, MOUSE answered. The key is to tell the PC that it is a MOUSE and supports the HID protocol. Due to limited space, they will not be listed in detail.
3. Send MOUSE information to PC
During the Enumeration process, MOUSE will tell the PC the format of subsequent X, Y, Z, and key press information. When MOUSE takes action, it only needs to return the data to the PC in this format. The PC HID driver will do the rest.
Previous article:Design of USB/PS2 MOUSE using 4BIT OTP microcontroller
Next article:High-precision frequency regulator based on AVR microcontroller
Recommended ReadingLatest update time:2024-11-16 19:40
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to get the current memory address when STM32 uses DMA? (Solved)
- The 24A MOS tube can replace the 25N50 model parameters and is used in AC-DC switching power supplies.
- Playing with Zynq Serial 3 - Introduction to AXI Bus Protocol 1
- PHYTEC's imx8mplus development board review
- [RVB2601 Creative Application Development] 4. Use RTC to record time
- ADN8834 does not work or has current overshoot
- A brief discussion on the bus differences of ARM Cortex-m0/m4 series
- Please help me interpret this article about tl431 bias current
- Disable automatic layer selection for routing
- [National Technology N32 MCU Development Package] --N32L40x Series