1. Flash memory
(1) Flash memory is a non-volatile memory, which can be divided into two types according to its structure: NOR Flash and NAND Flash.
(2) Characteristics of Flash memory:
A. Block structure: Physically divided into several blocks, which are independent of each other.
B. Erase before writing: Flash write operations can only change data bits from 1 to 0, not from 0 to 1. Therefore, an erase operation must be performed before writing to the memory to initialize the data bits to be written to 1. The smallest unit of an erase operation is a block, not a single byte.
C. Operation Instructions: To perform a write operation, a series of special instructions (NORFlash) or a timing sequence (NANDFlash) must be entered before data can be written.
D. Bit Reversal: Due to the inherent characteristics of Flash memory, occasional data errors of one or more bits may occur during read and write operations. Bit reversals are unavoidable and can only be corrected post-processed using other methods.
E. Bad Blocks: Once a block is damaged, it cannot be repaired. The results of operations on damaged blocks are unpredictable.
(3) Features of NOR Flash:
Applications can run directly in flash memory, eliminating the need to load code into system RAM. NOR Flash offers high transfer efficiency and is cost-effective for small capacities of 1MB to 4MB, but its very low write and erase speeds significantly impact its performance.
(4) Characteristics of NAND Flash
It can achieve extremely high cell density, resulting in high storage density, and its write and erase speeds are also very fast, which is why all USB flash drives use NAND flash as their storage medium. The difficulty in using NAND flash lies in the fact that flash memory requires a special system interface.
(5) Differences between NOR Flash and NAND Flash:
A. NOR Flash has a slightly faster read speed than NAND Flash.
B. NAND Flash has a much faster erase and write speed than NOR Flash.
C. NAND Flash has poor random read capability, but is suitable for continuous reading of large amounts of data.
D. NAND Flash has an SRAM interface with enough address space for addressing, making it easy to access every byte within it. NAND Flash uses an 8-bit bus for address, data, and command (some companies use 16 bits), requiring complex I/O interfaces to serially access data for each read/write operation.
E. NOR Flash generally has a smaller capacity, typically between 1MB and 8MB; NAND Flash is only used in products with capacities of 8MB or more. Therefore, NOR Flash is primarily used for code storage media, while NAND Flash is suitable for data storage.
F. The maximum number of erase/write cycles per block in NAND Flash is one million, while in NOR Flash it is one hundred thousand.
G. NOR Flash can be connected like other memory, used very directly, and code can be run directly on it; NAND Flash requires a special I/O interface, and a driver must be written before any other operations can be performed. Because designers must never write to bad blocks, this means that a virtual image must be maintained on NAND Flash from the beginning.
H and NOR Flash are used in fields where data reliability is critical, such as code storage, communication products, and network processing, and are known as code flash memory; while NAND Flash is used in fields where storage capacity is critical, such as MP3 players, memory cards, and USB flash drives, and is known as data flash memory.
2. RAM memory
(1) Characteristics of SRAM:
SRAM stands for Static Random Access Memory. It retains a single value as long as power is supplied, has no refresh cycle, and is composed of flip-flops as its basic unit. It has low integration density, with each SRAM cell consisting of six transistors, thus its cost is relatively high. It has a high data rate and is often used in cache memory.
SRAM typically has four pin types:
CE: Chip Select signal, active low.
R/W: Read/write control signal.
ADDRESS: A set of address lines.
DATA: A set of bidirectional signal lines used for data transmission.
(2) Characteristics of DRAM:
DRAM stands for Dynamic Random Access Memory. It is a type of semiconductor memory that stores data in the form of electrical charge. Each memory cell consists of a transistor and a capacitor, with data stored in the capacitor. Because capacitors can lose charge due to leakage, DRAM devices are unstable. They must be refreshed regularly to retain data in memory.
DRAM interfaces are relatively complex and typically have the following pins:
CE: Chip Select signal, active low.
R/W: Read/write control signal.
RAS: Row Address Strobe Signal, usually connected to the high-order bits of the address.
CAS: Column address strobe signal, usually connected to the low-order part of the address.
ADDRESS: A set of address lines.
DATA: A set of bidirectional signal lines used for data transmission.
(3) Characteristics of SDRAM:
SDRAM stands for Synchronous Dynamic Random Access Memory. "Synchronous" means the memory requires a synchronized clock for operation; internal command transmission and data transfer are based on this clock. "Dynamic" means the memory array needs constant refreshing to prevent data loss. It typically operates at a clock frequency of only 133MHz.
(4) Characteristics of DDRAM
DDRAM stands for Double Data Rate Synchronous Dynamic Random Access Memory, also known as DDR. DDRAM is based on SDRAM technology. SDRAM transmits data only once per clock cycle, during the rising phase of the clock; while DDR memory transmits data twice per clock cycle, once during the rising phase and once during the falling phase. At a clock frequency of 133MHz, DDR memory bandwidth can reach 133 × 64b / 8 × 2 = 2.1GB/s.
3. Hard drive, optical disc, CF card, SD card
4. GPIO Principles and Structure
GPIO is the most basic form of I/O, consisting of a set of input or output pins. Some GPIO pins can be programmed to change their operating direction, typically using two control registers: a data register and a data direction register. The data direction register sets the port's direction. If a pin is set as an output, the data register controls its state. If a pin is set as an input, its state is controlled by the logic layer on the pin.
5. A/D interface
(1) An A/D converter is a circuit that converts analog electrical quantities into digital quantities. There are many methods to achieve A/D conversion, and the commonly used methods are the counting method, the dual-integral method, and the successive approximation method.
(2) Counting A/D Conversion Method
Its main circuit components include: comparator, counter, D/A converter and standard voltage source.
In simple terms, its working principle is as follows: there is a counter that increments by 1 starting from 0. Each increment is used as the input of the D/A converter, generating a comparison voltage VO that is compared with the input analog voltage VIN. If VO is less than VIN, the counter continues to increment until VO is greater than VIN. At this point, the accumulated value of the counter is the output value of the A/D converter.
This conversion method is simple, but relatively slow, especially when the analog voltage is high. For example, for an 8-bit A/D converter, if the input analog quantity is at its maximum value, the counter needs to count from 0 to 255, performing 255 D/A conversions and voltage comparisons to complete the conversion.
(3) Dual-integral A/D conversion method
Its main circuit components include: integrator, comparator, counter and standard voltage source.
Its working principle is as follows: First, the circuit integrates the input voltage to be measured for a fixed time. Then, it switches to a standard voltage and performs reverse integration with a fixed slope. After a certain time, the reverse integration returns to the initial value. Because a fixed slope is used, the time for reverse integration with the standard voltage is proportional to the input analog voltage value. The larger the input analog voltage, the longer the time for reverse integration to return to the initial value. By measuring the time spent on reverse integration using a standard high-frequency clock pulse, the digital value corresponding to the input analog voltage can be obtained, thus completing the A/D conversion.
Its characteristics include strong resistance to power frequency interference and high conversion accuracy, but slow conversion speed, with a conversion frequency usually less than 10Hz. It is mainly used in digital test instruments, temperature measurement, and other fields.
(4) Successive approximation A/D conversion method
Its main circuit components include: a comparator, a D/A converter, a successive approximation register, and a reference voltage source.
Its working principle is essentially a bipartite search method, similar to the operation of a balance. During A/D conversion, the D/A converter increments the number of bits from the most significant bit to the least significant bit, generating different output voltages. The input voltage is then compared with the output voltage. First, the most significant bit is set to 1, which is equivalent to comparing half of the reference voltage with the input voltage. If the input voltage is less than half the reference voltage, the most significant bit is set to 0; otherwise, it is set to 1. Then, the next most significant bit is set to 1, which is equivalent to performing another bipartite search within the half-range, and so on, approximating the reference voltage each time.
Its characteristics include high speed and high conversion accuracy. For an N-bit A/D converter, only M clock pulses are needed to complete the conversion. It can generally be used to measure the changes in the transition process of tens to hundreds of microseconds, and it is currently the most widely used conversion method.
(5) Key indicators of A/D conversion (some simple calculations may be tested)
A. Resolution: Reflects the A/D converter's ability to respond to minute changes in the input, usually expressed as the analog voltage level corresponding to the least significant bit (LSB) of the digital output. An n-bit A/D converter can reflect 1/2n of the full-scale analog input level.
B. Range: The range of analog input voltages that can be converted, which is divided into two types: unipolar and bipolar.
C. Conversion time: The time required to complete one A/D conversion; its reciprocal is the conversion rate.
D. Accuracy: Accuracy and resolution are two different concepts. Even with high resolution, accuracy may be insufficient due to factors such as temperature drift and linearity. Accuracy can be expressed in two ways: absolute accuracy and relative accuracy. Absolute accuracy is usually expressed as a fraction of the least significant bit (LSB) of the digital quantity, while relative accuracy is expressed as a percentage of the full-scale analog voltage range.
For example, a 10-bit A/D chip with a full-scale range of 10V and an absolute accuracy of ±1/2 LSB has a quantization unit of 10/1024 = 9.77mV, an absolute accuracy of 9.77mV/2 = 4.88mV, and a relative accuracy of 0.048%.
6. Basic D/A Interface
(1) A D/A converter converts digital quantities into analog quantities.
(2) In integrated circuits, a T-type network is usually used to convert digital quantities into analog current, and then an operational amplifier converts the analog circuit into analog voltage. D/A conversion actually requires the two steps mentioned above.
(3) Classification of D/A converters:
A. Voltage output type: often used as a high-speed D/A converter.
B. Current output type: Generally used for external operational amplifiers.
C. Multiplicative type: Can be used as a modulator and to digitally attenuate the input signal.
(4) The main indicators of D/A converters are: resolution, settling time, linearity, conversion accuracy, and temperature coefficient.
7. Keyboard Interface
(1) Two types of keyboards: linear keyboard and matrix keyboard.
(2) There are usually two methods to identify closed keys on the keyboard: row scanning method and row reversal method.
(3) Row scanning is a commonly used method for recognizing keystrokes on a matrix keyboard. This method involves two steps:
A. Identify which column of keys on the keyboard is pressed: Set all row lines to low level and check if the level of each column line is low. If a column line is low, it means that a key in that column is pressed; otherwise, it means that no key is pressed.
B. If a key is pressed in a column, identify which row on the keyboard was pressed: set each row to low level and the remaining rows to high level, check the changes in each column, and if the column level becomes low level, it can be determined that the key at the intersection of this row and column was pressed.
8. Display Interface
(1) The basic principle of LCD is to control whether light passes through different liquid crystal cells by supplying power to them, thereby achieving the purpose of display.
(2) There are two ways to provide a light source for an LCD: projection and reflection. Laptop LCDs are projection type, with a light source behind the screen, so an external light source is not required. LCDs used in general microcontrollers are reflection type, requiring an external power supply and operating by reflecting light. Electroluminescence (EL) is one way a liquid crystal display (LCD) provides a light source.
(3) According to the liquid crystal driving method, common LCDs can be divided into three categories: twisted nematic (TN), super twisted nematic (STN) and thin film transistor (TFT).
(4) There are two types of LCDs sold on the market: LCD display modules with driving circuits, which are driven by bus; and LCD displays without driving circuits, which use controller scanning.
(5) Normally, when the LCD controller is working, it reads the data at the specified address (display buffer) in the SDRAM directly through the SDRAM controller via the DMA request bus. This data is converted into the LCD screen scanning data format by the LCD controller and directly drives the LCD display.
(6) The VGA interface is essentially an analog interface, and generally uses a unified 15-pin interface, including 2 NC signals, 3 display data buses, 5 GND signals, 3 RGB color components, 1 horizontal sync signal and 1 vertical sync signal. The color components use the RS343 standard defined by EIA.
9. Touchscreen interface
(1) According to the working principle, touch screens can be divided into several types: surface acoustic wave screens, capacitive screens, resistive screens and infrared screens.
(2) The touch screen is controlled by a professional chip, such as ADS7843.
10. Audio interface
(1) Basic principle: The data input by the microphone is decoded by the audio codec to complete the A/D conversion. The decoded audio data is sent to the DSP or CPU for corresponding processing through the audio controller. Then the data is sent to the audio encoder through the audio controller. After encoding and D/A conversion, it is output by the speaker.
(2) There are many digital audio formats, the most commonly used being the following three:
A. PCM (Physical Collections and Multimedia) audio: This is the data format used by CDs and DVDs. Its sampling frequency is 44.1kHz. At 16-bit resolution, the PCM audio data rate is 1.41Mb/s; at 32-bit resolution, it is 2.42Mb/s. A 700MB CD can store approximately 60 minutes of music in 16-bit PCM data format.
B. MPEG Layer 3 Audio (MP3): The audio format used by MP3 players. Stereo MP3 data rates range from 112kb/s to 128kb/s.
C. ATSC Digital Audio Compression Standard (AC3): Digital audio encoding standard for digital TV, HDTV and movies. The data rate of stereo AC3 encoding is 192kb/s.
(3) IIS is a commonly used serial audio digital interface for encoding or decoding audio data. The IIS bus only processes audio data; other control signals, etc., need to be transmitted separately. IIS uses three serial bus lines: data line SD, field select line WS, and clock signal line SCK.
(4) When the data field widths of the receiver and the sender are different, the sender does not consider the receiver's data field width. If the data field sent by the sender is smaller than the system field width, it is padded with 0s in the lower bits; if the data width of the sender is greater than the width of the receiver, the portion exceeding the LSB is truncated. The field selection WS is used to select the left or right audio channel; WS=0 indicates selection of the left channel; WS=1 indicates selection of the right channel. In addition, WS allows the receiving device to store the previous byte and prepare to receive the next byte.