Today I conducted an AD experiment and would like to share some insights.
Using chips: ADC0832, 89S52
The circuit diagram is as follows:

Today was my first time looking at the ADC0832 data sheet, and I was quite confused. I found a good piece of Chinese material on it.
Actually, the timing diagram in the English manual is quite clear, but unfortunately, my English is not good enough to understand it.
Regardless of whether you want to use CH1 or CH0, you need to properly configure the DI and DO of the ADC0832. DI determines the start of the chip’s operation and the selection of CH0 or CH1, while DO is the output data port. These two ports do not operate simultaneously; controlling them with a single I/O port is sufficient. Teacher Du Yang used the following circuit to save one I/O port. As shown:

The key points in the above circuit are how to start the ADC0832 and how to read data from the ADC0832 to display on the digital tube.
The code is as follows, compiled using Keil uVersion, achieving the desired effect:
See original text for code.
In ReadADC(), the code for starting the ADC0832 is generic, allowing you to start CH0 or CH1 based on the channel value obtained. This way, I can expand the keyboard to input a channel to control which CH to activate.
By the way, I also familiarized myself with bit manipulation in C language today:

In ReadADC(), tmp=channel&0x01; uses bitwise AND to extract the last bit.
In reg51.h, P0, P1, P2, and P3 are defined as sfr types, where sfr is used to define the addresses of special function registers, and sbit is used to define certain special bits. Therefore, CLK, DI, and DO in the program correspond to individual ports of P1, which are essentially bits. Thus, the line DI=tmp; assigns a char to a bit, and as long as tmp is not 0, DI will remain 1. Therefore, each bit in channel must be extracted and assigned to DI to achieve the desired effect of assigning the low three bits of the channel to DI in sequence.
This program uses the header file intrins.h, which defines intrinsic functions in Keil C. In ReadADC(), a _nop_() empty operation is used.
/*————————————————————————–
INTRINS.H
Intrinsic functions for C51.
Copyright (c) 1988-2004 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
————————————————————————–*/
#ifndef __INTRINS_H__
#define __INTRINS_H__
extern void _nop_ (void);
extern bit _testbit_ (bit);
extern unsigned char _cror_ (unsigned char, unsigned char);
extern unsigned int _iror_ (unsigned int, unsigned char);
extern unsigned long _lror_ (unsigned long, unsigned char);
extern unsigned char _crol_ (unsigned char, unsigned char);
extern unsigned int _irol_ (unsigned int, unsigned char);
extern unsigned long _lrol_ (unsigned long, unsigned char);
extern unsigned char _chkfloat_(float);
extern void _push_ (unsigned char _sfr);
extern void _pop_ (unsigned char _sfr);
#endif
Endless cycle, the East Palace divine seal of indifference 