The F020 has a 1.2V, 15×10-6/℃ bandgap voltage reference generator and a two-times gain output buffer on the chip. The 2.4V reference voltage (VREF) can be connected to ADC0, ADC1 and DAC through external pins. VREF has an external load capacity of 200μA (it is recommended to connect a load resistor to ground when driving an external load). When the ADC uses bias, bit 1 in the reference source control register REFxCN must be set to "1"; if it is set to "0", the internal bias is turned off. At this time, the external reference voltage can be used through the VREF pin (pin 12). The external reference voltage must be less than VAV±0.3V (and greater than 1V). When the ADC or DAC is not used, bit 0 of REFxCN can be set to "0" to put the buffer amplifier in power saving mode (output is high impedance).
When bit 4 of REF0CN is set to "0", ADC0 is biased with VREF, and when it is set to "1", it is biased with DAC0 output; when bit 3 of REF0CN is set to "0", ADC1 is biased with VREF, and when it is set to "1", it is biased with AV+.
In the ADC circuit of F020, there is an internal amplifier (PGA) with programmable gain behind the input multiplexer AMUX. It is particularly useful when the voltage signal ranges of the inputs of the analog channels are very different, or when a signal with a large DC offset needs to be amplified (in differential input mode, the DAC can be used to provide a DC offset). The setting method is to configure bits 2 to 0 in ADCxCF (000 corresponds to a PGA gain of 1; 001 corresponds to 2; 010 corresponds to 4; 011 corresponds to 8; 10x corresponds to 16, and 11x corresponds to 0.5). The gain here also works on the temperature sensor signal. When the gain is 1, VTEMP=0.002 86(V/℃)(TEMPC)℃+0.776V.
ADC data and control
Corresponding to single-ended input, the ADC result data word format is: 0V--0000, VREF--0FFF or FFF0.
Corresponding to differential input, the ADC result data word format is 2's complement: VREF--07FF, 0--0000, -VREF--F800 or 8000.
Setting Bit 0 of ADCxCN to "0" will right-align the result; setting it to "1" will left-align the result. When the input is differential, the extra high bits generated by right alignment are the sign extension bits.
The C8051F series microcontroller also has a data-related window interrupt generator or programmable window detector, also called ADC upper (lower) data register ADC0G (L) TH (L), which monitors a key voltage in the background. When the conversion data is within (or outside) the specified window, the controller is requested to request a conversion end interrupt. When an interrupt is required within the window, the upper limit register LT is loaded with the high window number, and the lower limit register GT is loaded with the low window number; if an interrupt is required outside the window, the lower limit register GT is loaded with the high window number, and the upper limit register LT is loaded with the lower window number.
When reset, the status of the ADC part is: internal voltage reference buffer is off, internal bias is off, internal sensor is off, ADC is disabled, conversion result data register is right-aligned, 12-bit ports are all single-ended inputs, ports point to AIN0, SAR conversion clock is 33 system clocks, internal amplifier gain is 1, lower limit data register is FFFFH, and upper limit data register is 0000H.
Comprehensively considering the various elements related to ADC in F020, in order to correctly apply the ADC function, the following sequence should be followed: set reference voltage > set ADC enable > set tracking (start) mode > set data alignment > configure channel > select channel > set conversion clock and gain > set window detection upper and lower limits > start conversion. The sequence of operating SFR (taking 12 bits as an example) is: REF0CN > ADC0CN > AMX0CF > AMUX0SL > ADC0CF > ADC0GTH > ADC0GTL > ADC0LTH > ADC0LTL > ADC0CN or other start-up methods. C8051F020 (F020 for short) is a mixed signal SOC type 8-bit microcontroller launched by Cygnal Corporation in Texas, USA. It belongs to the F02X sub-series of the C8051F series. Its performance-price ratio is very competitive in the current application field. F020 has 8-channel 12-bit A/D conversion (ADC) interface and 8-channel 8-bit online programmable (ISP) ADC circuit. There are 15 special function registers (SFR) on the chip related to ADC control, which are:
AMUX0SL-AMUX0 channel selection register, the reset value is 00000000;
AMX0CF-AMUX0 configuration register, reset value is 00000000;
ADC0CF-ADC0 configuration register, reset value is 11111000;
ADC0CN-ADC0 control register, reset value is 00000000;
ADC0H-ADC0 data word MSB register, reset value is 00000000;
ADC0L-ADC0 data word LSB register, reset value is 00000000;
ADC0GTH-ADC0 lower limit data high byte register, the reset value is 11111111;
ADC0GTL-ADC0 lower limit data low byte register, the reset value is 11111111;
ADC0LTH-ADC0 upper limit data high byte register, the reset value is 00000000;
ADC0LTL-ADC0 upper limit data low byte register, the reset value is 00000000;
AMX1SL-AMUX1 channel selection register, the reset value is 00000000;
ADC1CN-ADC1 control register, reset value is 00000000;
ADC1CF-ADC1 configuration register, reset value is 11111000;
ADC1-ADC1 data word register, reset value is 00000000;
REF0CN-reference voltage control register, reset value is 00000000;
ADC is an important function of mixed-signal controllers. If you want to be proficient in application programming, you must have a clear overall understanding of its related factors.
1) ADC accuracy and channels
F020 uses T QFP 100 package, and there are 8 chip pins (pins 18-25) dedicated to analog input, which are the input ends of 8-channel 12-bit ADC. The conversion accuracy of each 12-bit channel is its own ±1LSB (least significant bit). In fact, there is only one corresponding 12-bit successive approximation register (SAR) ADC, and there is a multiplexer with 9-channel input (configurable analog multiplexer AMUX) between it and each input end. The 9th channel of AMUX is connected to the temperature sensor. In F020, the 12-bit ADC is called ADC0, and there are 8-channel 8-bit in-system programmable (ISP) ADC circuits called ADC1. Its 8 external pins are multiplexed with P1 port, and the internal structure is similar to ADC0, except that the number of converted bits is 8 bits and the conversion accuracy is 8 bits ±1LSB.
Each pair of ADC0 ports can be programmed to be single-ended input or differential input respectively. The port pairing for differential input is 0-1, 2-3, 4-5, 6-7, which is determined by the lower 4 bits of the channel selection register AMUX0SL and the lower 4 bits of the channel configuration register AMUX0CF. In AMX0CF, bits 3 to 0 correspond to 2 pin channels each. Bit value = 0 indicates an independent single-ended input (the reset value is single-ended input); bit value = 1 indicates a differential input pair. When selecting differential input corresponding to AMX0CF, AMUX0SL is only valid when an even number (including 0) channel is selected (Note: When the lower 4 bits of AMUX0SL are 1xxx, the temperature sensor is selected regardless of the value of the lower 4 bits of AMX0CF).
When bit 3 of REF0CN is set to "1", the temperature sensor is allowed to be used; when it is set to "0", the output of the temperature sensor is high impedance. The value of the temperature sensor can be used to correct the nonlinearity of the parameter or record and adjust the data related to temperature.
2) ADC speed and startup
The ADC rate in the C8051F series microcontrollers can be programmed, but at least 16 system clocks are required. Generally, a tracking/holding capture time of 3 system clocks (>1.5μs) is automatically added before conversion. The method to set the ADC rate in F020 is to configure bits 7~3 of the register ADCxCF (x is 0 or 1), and its reset value is 11111 (bits 7~3 = SYSCLK/CLKSAR-1).
Generally, the ADC must be in tracking mode before starting. If bit 6 of the control register ADCxCN is "0", it will always be in tracking mode (at this time, starting any of the four start modes can be 3 system clocks faster than starting tracking); if it is "1", there are four tracking start modes to choose from, that is, assign values to bits 3~2 in ADCxCN; 00 is tracking when writing 1 to ADBUSY (software command); 01 is timer 3 overflow tracking; 10 is CNVSTR rising edge tracking (external signal); 11 is timer 2 overflow tracking.
When reset, bit 7 of ADCxCN is 0, which means it is in shutdown state. At the end of each conversion, bit 5 of ADCxCN is "1", and the falling edge of bit 4 (busy flag) triggers the end interrupt. These status bits can also be queried by software.
Previous article:Analysis of Several Solutions for MCU Speed Measurement
Next article:Connection circuit between X2401 serial EEPROM and 8031
- Popular Resources
- Popular amplifiers
- Learn ARM development(14)
- Learn ARM development(15)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Allwinner V853 heterogeneous AI intelligent vision development board review - Solution to the problem of constant restart and reflashing of firmware
- 25 "Million Miles" Raspberry Pi Car - Nam Wheel Control
- Is it better to settle a head injury privately or publicly?
- [RVB2601 Creative Application Development] Ultrasonic pressure sensor debugging and LED/OLED display
- EEWORLD University Hall----Infinite sensor network and radio frequency identification technology RFID
- National Technology's low-power MCU, with dynamic power consumption as low as 60μA/MHz, helps devices have ultra-long battery life
- How to regulate negative emotions?
- EEWORLD University Hall----Live Replay: Applications and Techniques of Keysight Oscilloscopes in General Electronic Measurements
- No001. The long-awaited release - received the first post of the development board
- What would you think if the Internet of Things and AI were added to the electronic design competition?