/* Name: ADC0809 digital-to-analog conversion and display
Description: ADC0809 sampling channel 3 input
Analog quantity, the converted result is displayed on the digital tube.
*/
#include
#define uchar unsigned char
#define uint unsigned int
//Digital tube segment code for each digit (common cathode)
uchar code DSY_CODE[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit CLK=P1^3; //clock signal
sbit ST=P1^2; //Start signal
sbit EOC=P1^1; //Conversion end signal
sbit OE=P1^0; //output enable
//Delay
void DelayMS(uint ms)
{
uchar i;
while(ms--) for(i=0;i<120;i++);
}
// Display the conversion result
void Display_Result(uchar d)
{
P2=0xf7; The 4th digital tube displays the unit digit
P0=DSY_CODE[d%10];
DelayMS(5);
P2=0xfb; The third digital tube displays the tens digit
P0=DSY_CODE[d%100/10];
DelayMS(5);
P2=0xfd; The second digital tube displays the hundreds digit
P0=DSY_CODE[d/100];
DelayMS(5);
}[page]
//Main program
void main()
{
TMOD=0x02; //T1 working mode 2
TH0=0x14;
TL0=0x00;
IE=0x82;
TR0=1;
P1=0x3f; //Select channel 3 (0111) of ADC0809 (P1.4~P1.6)
while(1)
{
ST=0;ST=1;ST=0; //Start A/D conversion
while(EOC==0); //Wait for the conversion to complete
OE=1;
Display_Result(P3);
OE=0;
}
}
//T0 timer interrupt provides clock signal to ADC0808
void Timer0_INT() interrupt 1
{
CLK=~CLK;
}
Previous article:Electronic System Thermal Management Solutions
Next article:Microcontroller C language programming: using ADC0808 to control PWM output
- Popular Resources
- Popular amplifiers
- 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)
- Learn ARM development (4)
- Learn ARM development (6)
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
- 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?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- System performance indicators of single-phase sine wave inverter
- PADS PCB board partial circuit replication
- Phantom Power in Audio Equipment
- View Circuit-CSA and System
- Delayed season planning and preparation progress
- Free Download | 2018 ADI Solution Selection Compilation
- Today's live broadcast: Rochester Electronics Semiconductor Full Lifecycle Solutions Help You Meet the Challenges of Supply Chain Disruptions and Component Discontinuations
- Sharing a carefully adjusted hysteresis comparator
- The simulation result of LC parallel resonance frequency is inconsistent with the calculation. Is it because the component model is not selected correctly?
- Using Bluetooth module for fast IoT circuit design