Usually, when we use the AD function of SN microcontroller, if we choose external reference voltage, we can use cheap TL431 to provide high stability voltage of about 2.5V. Even if the 240℃ high temperature electric soldering iron is close to it, the output fluctuation of TL431 is only 1~3mV. At this time, the system can convert the 12BIT AD obtained by 5V reference into 12BIT AD by 2.5V reference. This is a very cost-effective measure! ---- On the one hand, it is equivalent to using a 2x amplification without offset, offset and temperature drift amplifier circuit. On the other hand, it makes the reference value of AD have a temperature coefficient of up to 50ppm!
I encountered a problem when using the external reference and AD function of 2743 recently:
AD The reading is far from the expected value! On the adapter board of the simulator, the reference voltage measured by AVREFH is not 2.5V, but 5.0V. What's going on?
Check the external/internal reference AVREFH plug on the simulator, it has been unplugged! (Must be unplugged!)
Thinking that an external reference voltage is needed, the pin of AVREFH on the adapter board is directly connected to the external reference TL431 to see if it is correct? As a result, the voltage becomes slightly larger than 2.5V by 0.1~0.3V and unstable. Because I was prepared in advance, I kept touching TL431 and found that its temperature rose. I felt that this was wrong, so I quickly disconnected AVREFH from TL431.
The adapter board and the target board have a one-to-one pin relationship. The external reference has actually reached the corresponding pin of the chip. Why can't AVREFH be measured on the adapter board?
Checking the adapter board, it turns out that these interfaces use a NLAS4501DFT2G The general single-pole single-throw analog switch is used for switching! For this purpose, I temporarily checked the manual of the chip online. It took a lot of effort!
Carefully measured the control pins of the NLAS4501DFT2G chip and found that it was different from the instruction of "selecting external reference". What's going on?
Reread the data sheet of 2743 again. In the ADM register, there is an additional FAVREFH bit compared to the usual SN with AD microcontroller. If it = 1, the external reference is selected! ---- Here, there is usually no mistake! The instruction is correct!
Let's take a look at the example it gives:
ADC operation example
ADC:
; Reset ADC.
CLR ADM ; Clear ADM register.
; Set ADC clock rate and ADC resolution.
MOV A, #0nmn0000b ; nn:ADCKS[1:0] represents ADC clock rate.
B0MOV ADR, A ; m represents ADC resolution.
; Set ADC reference high voltage.
B0BCLR FAVREFH ; Internal VDD.
or
B0BSET FAVREFH ; External reference source.
; Set ADC input channel.
MOV A, #value1 ; Set P4CON to select ADC input channel.
B0MOV P4CON, A
MOV A, #value2 ; Set ADC input channel to input mode.
B0MOV P4M, A
MOV A, #value3 ; Disable internal pull-up resistor of ADC input channel.
B0MOV P4UR, A
; Enable ADC.
B0BSET FADCENB
; Execute ADC 100us start time delay loop.
CALL 100usDLY ; 100us delay loop.
; Select ADC input channel.
MOV A, #value ; Set ADCHS[2:0] to select ADC input channel.
OR ADM, A
; Enable ADC input channel.
B0BSET FGCHS
; Enable ADC interrupt function.
B0BCLR FADCIRQ ; Clear ADC interrupt request.
B0BSET FADCIEN ; Enable ADC interrupt function.
; Start AD conversion.
B0BSET FADS
OK! Problem found! ----- Look at this sentence: CLR ADM ; Clear ADM register. ---- Here, BIT3 is changed back to 0!
In addition to AD conversion, a single-chip microcomputer system spends most of its time running other programs. FAVREFH (ADM.3) will change from 1 to 0 and then from 0 to 1 under program instructions! Constantly switching the external reference/internal reference will of course cause the external reference to change constantly!
Therefore, delete this sentence: "CLR ADM; clear ADM register"!
And, during the first system initialization after power-on, set FAVREFH (ADM.3)=1! In the future, you must remember not to move this bit! When selecting the AD channel, you can use the OR instruction or the AND instruction to change ADM. Of course, if you pay enough attention, you can still use MOV ADM, #value to assign values!
For example:; B3: FAVREFH=1 external reference source.
;Select ADC input channel:
MOV A,#098H ;=P40----FAVREFH (ADM.3)=1
;or
MOV A,#099H ;=P41----FAVREFH (ADM.3)=1
;or
MOV A,#09AH ;=P42----FAVREFH (ADM.3)=1
;or
MOV ADM,A
ZB1 FADS; Start AD conversion.
;................
After this treatment, the AVREFH pin on the adapter board is 2.5V, stable! The AD conversion reading has also become normal!
------ Of course, P4M, P4UR, P4CON and other related registers still need to be set correctly!
This experience is specially posted for friends to refer to when using 2743! ---- As the application deepens, if there are more strange problems, post them again ! [ page ]
=== ... Pin configuration Bidirectional input and output IO port: P0, P1, P4 IO port with wake-up function: P0, P1 Level conversion IO port with pull-up resistor: P0, P1, P4 OP-amp/comparator pins: P1, P4 ADC input pins: P4.0~P4.7 Here, I don’t see why I encountered the problem! I checked the SN8P2743.INC file in the software folder, and the content of the P0 port in the file is as follows: P0M EQU 0B8H FP06M EQU P0M.6 FP05M EQU P0M.5 FP03M EQU P0M.3 FP02M EQU P0M.2 FP00M EQU P0M.0 P0 EQU 0D0H FP06 EQU P0.6 FP05 EQU P0.5 FP04 EQU_R P0.4; read only FP03 EQU P0.3 FP02 EQU P0.2 FP01 EQU_W P0.1; Write only FP00 EQU P0.0 Notice that there is one read-only bit and one write-only bit in the P0 port! ----- For a group of ports with read-only bits, it does not affect the bit operation of other bits. Does it mean that there is a write-only bit? I checked the chip manual again and saw the write-only bit FP01 in the pin description: P0.1/PWM0 I/O P0.1: open-drain output pin. PWM0: PWM output pin and pulse output pin. Let's take a look at the system register content of port P0: I/O port mode Register PnM controls the working mode of the I/O port. 0B8H Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 P0M - P06M P05M - P03M P02M - P00M Read/Write - R/WR/W - R/WR/W - R/W After reset - 0 0 - 0 0 - 0 I/O port data register P0 0D0H Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 P0 - P06 P05 P04 P03 P02 P01 P00 Read/Write - R/WR/WRR/WR/WWR/W After reset - 0 0 0 0 0 0 0 Note: 1. When external reset is enabled by the compilation option, P04 remains 1. 2. If you need to set a certain bit (P0.n) of the P0 register, it is recommended to use the "MOV" or "B0MOV" instruction instead of the "read & modify write" type instruction (such as BSET, BCLR, B0BSET, B0BCLR...), otherwise after executing these instructions, the write-only bit P0.1 of the P0 register will be changed. The original problem is: if a certain bit of a group of ports is a write-only bit, in order to avoid the "read-modify" of the bit operation instruction destroying the state of the write-only bit, therefore, the bit operation instruction cannot be used for the other bits of this group of ports! This situation is rarely encountered, and the I/O configuration instructions in the chip manual are not specific and clear enough. ----- In order to avoid similar troubles when using 2743, it is posted for your reference! === ...
Pay attention to the use problems and solutions of 2743's P0 port:
I recently used 2743 to do a project, and I did encounter some troubles when using its P0 port!
First, its P0.1 can only be used as an output. It is an open-drain output. (In normal I/O mode). It cannot output a high level!
Secondly, this group of ports cannot use bit operation instructions, which is very inconvenient!
If it is used as a digital tube pen segment driver, the low level is effective. If the decimal point position is included, it cannot be quickly set through bit operation instructions!
First read the port status into a temporary RAM, then operate the decimal point, and then send it back to the P0 port!
At this time, an error will occur, and the status of P0.1 will be wrong!
Using AND and OR instructions to operate, errors will still occur! --- It's a bit inexplicable!
Pay attention: There are no such errors on the emulator. The errors are only discovered after the chip is burned!
Calm down, re-read the chip manual, and finally realize it! ---- P0.1 is a write-only bit, not readable! It is wrong to read it in!
Any instruction that goes through the "read-modify-write" process will make an error when operating it!
Solution:
Use a "shadow" register EME of port P0 to specifically deal with the output of port P0. This is not only convenient, but also consistent with the practices of other chips! All output operations on port P0 become operations on this shadow register, and then "MOV_ P0, EME" is performed in time! After
this treatment, the problem of incorrect operations on port P0 is better avoided. ------ In input mode, it can be read bit by bit, only P0.1 cannot be read !
=== ... , Comparator 2. All three comparators have rail-to-rail outputs, which means that under a 5V power supply, the high/low level output amplitudes almost reach the 5V and GND levels! (There is also an amplifier inside the chip, and the amplifier test has been posted!) All three comparators can be used as ordinary comparators or special comparators. The so-called special is that it can trigger or stop the PWM output pulse of the TC0 timer. Compared with conventional integrated circuit comparators, there are more options, such as the comparator flip direction and interrupt entry! You can choose whether to use the comparator output pin (shared with ordinary I/O ports). If you don't use hardware pins, it's just the software that processes the results or data internally, which can save 3 I/O ports. This is a major feature! Comparator 1 and Comparator 2 are even more interesting. The software can select the internal reference to the in-phase input as the reference voltage. At this time, you can also use no hardware pins and become a fully functional comparator with only one external pin! -------- Great! The comparator is an important component for comparing the size of two voltages. I tested Comparator 0 by using two 1% precision 3K The resistor is connected in series to 5V and GND, and the middle is 5V/2. This 2.5V is connected to the inverting input pin of comparator 0, and then the inverting input voltage of comparator 0 is given by the fine adjustment positioner. The voltage difference between the two input pins is measured in real time with a digital multimeter, and the comparison output is interrupted when it is low or high. The results are OK! It can also choose delayed output, but I did not use it, and never use delayed output. The action voltage of its comparison feels a bit large at first, up to hundreds of mV! Check the manual and add a 1u filter capacitor to each of the two input ports. As a result, the flip voltage difference drops to only about 0.6-0.8mV. ------ It is around 5/2=2.5V voltage, +0.8V, output=5V, -0.8V output=0!
Previous article:SN 8-bit MCU SN8P2743 Application Practice (3)
Next article:SN 8-bit MCU SN8P2743 Application Practice (1)
Recommended ReadingLatest update time:2024-11-16 15:38
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- SHT31 Review + Unboxing Test
- Matlab and Modelsim co-simulation error
- ST NUCLEO-G071RB evaluation application - Come and experience the new generation of entry-level 32-bit STM32, giving you the best cost-effective experience
- Classification of RFID readers and their advantages
- CC2640R2F supports Alibaba Cloud Link IoT platform
- Some understanding of MSP430 usage
- Speed up the development process with STM32CubeMX software
- 【Repost】Thirty Practical Experiences in Switching Power Supply Design (Part 1)
- Good book recommendation! A brief review of Luo's "Basics of Power Supply Design"
- Please give me some advice, is this an amplifier impedance issue?