SN 8-bit MCU SN8P2743 Application Practice (2)

Publisher:幸福自由Latest update time:2015-04-07 Source: eechinaKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
SN8P2743 is a newer model, which contains amplifier, comparator, AD converter and external reference voltage input....4K*16-bit space, which feels "cheap and good!"
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!












Keywords:MCU Reference address:SN 8-bit MCU SN8P2743 Application Practice (2)

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

How to use the nop function and delay calculation in the C language of the microcontroller
There are no empty statements in the standard C language. However, in C language programming of microcontrollers, it is often necessary to use several empty instructions to produce a short delay effect. This is easy to do in assembly language, just write a few nops. In keil C51, call the library function directly:
[Microcontroller]
CEVA provides voice user interface solution for TI SimpleLink™ Wi-Fi® wireless MCUs
CEVA provides voice user interface solution for TI SimpleLink™ Wi-Fi® wireless MCUs  CEVA’s WhisPro™ speech recognition and control software is now available for TI’s CC3235x series of MCUs, Ultra-low-power voice user interface brings powerful features to IoT terminals CEVA, Inc. (Nasdaq: CEVA), the world's leadin
[Internet of Things]
CEVA provides voice user interface solution for TI SimpleLink™ Wi-Fi® wireless MCUs
MCU Learning 5: Basic I/O Port Experiment - Lighting up the Diode
Experiment 1: Basic I/O port test: Lighting up a diode   1. Experimental phenomenon: 8 diodes light up at intervals.   2. Experimental purpose: To understand the simplest method of writing MCU programs; To understand the method of driving diodes at MCU I/O ports   3. Experimental task analysis: If we wan
[Microcontroller]
MCU Learning 5: Basic I/O Port Experiment - Lighting up the Diode
A brief discussion on several self-refresh methods of MCU Boot
The main function of the car software Boot program is to refresh the App program. In a specific customer project, Boot is also part of the customer's needs, and there is also a software development plan following the project (some call the Boot on the project CB, Customer Boot, in order to distinguish it from other Bo
[Microcontroller]
An article analyzing 51 microcontroller PWM dual servo control
  Introduction to PWM   Pulse width modulation is a very effective technology that uses the digital output of a microprocessor to control analog circuits. It is widely used in many fields from measurement and communication to power control and conversion.   Pulse width modulation is an analog control method that mod
[Microcontroller]
An article analyzing 51 microcontroller PWM dual servo control
Solenoid valve control program using stc89c52 microcontroller
The following is a program that uses the stc89c52 microcontroller to perform some simple control on the solenoid valve.     #include reg52.h sbit a=P1^0;//down switch     sbit b=P1^1;//rising sbit c=P1^2;//falling sbit d=P1^3;//upper limit sbit e=P1^4;//lower limit void main() {  a=1;//upper switch normally open  b=1
[Microcontroller]
Design of remote control of household appliances by telephone based on AT89C51 microcontroller and DTMF communication
introduction With the development of computer technology and telecommunications, remote communication through telephone lines has become more and more common. People usually use MODEM for communication, but in applications where the amount of communication data is not large and the communication rate is not high, we c
[Microcontroller]
Design of remote control of household appliances by telephone based on AT89C51 microcontroller and DTMF communication
51 MCU Tutorial: MCU Delay Program Analysis
In the last class, we already know that the symbols R7 and R6 in the program represent RAM units, which are used to store some data. Now let’s take a look at the meaning of other symbols. 〈MCU Delay Program〉 MOV: This is an instruction, which means to transfer data. Speaking of transfer, we all know
[Microcontroller]
51 MCU Tutorial: MCU Delay Program Analysis
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号