#include
#include
#define uint unsigned int
#define uchar unsigned char
#define N 128 /*define sampling length, such as 128 points*/
sbit BYTE=P1^0;
sbit RC=P1^1;
sbit BUSY=P1^2; /*Define special bits*/
int xdata array[128]; /*Define a signed integer of length N in the external memory*/
int ADS7804(void);
int ADS7804(void)
{
uint ul,uh;int u;
RC=0; /*Low level, enter conversion mode*/
ul=XBYTE[0xffff]; /*Generate read pulse, start A/D conversion*/
while(BUSY==0); /*Wait for conversion to complete*/
RC=1;BYTE=0; /*Enter read mode, select low byte*/
ul=XBYTE[0xffff]; /*Read the low 8 bits of the conversion result*/
BYTE=1; /*Select the high byte*/
uh=XBYTE[0xffff]&0x0f; /*Read the high 4 bits of the conversion result*/
u=uh*256+ul; /*Get a 12-bit conversion result*/
if(u>=0x0800)
u=u|0xf000; /*If it is a negative value, sign extension*/
return(u); /*Return the conversion result*/
}
void DAQ(uint interval)
{
uchar th,tl;
uint i;
interval=interval-5; /*Subtract the time 5μs for clearing TF0 and loading the initial value of the count*/
th=255-(interval/256);
tl=255-(interval%256); /*Calculate the initial value of the count*/
TMOD=0x01; /*Timer 0, mode 1 */
TH0=th; TL0=tl; /*Load the initial value of the count*/
TR0=1; /*Start timing*/
for(i=0;i
do{}while(!TF0); /*Query and wait for TF0 reset*/
TF0=0; /*Clear overflow flag*/
TH0=th; TL0=tl; /*Load initial count value*/
array[i]=ADS7804(); /*Sampling, storage*/
}
TR0=0; /*Stop timing*/
}
Previous article:P89LPC932 PWM DA Conversion
Next article:Philips 87LPC768 infrared decoding program
- Popular Resources
- Popular amplifiers
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- 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
- Low power mode of msp430f149
- GaN Reference Designs
- How to get started with embedded development?
- [Perf-V Review] Transplanting the Hummingbird E203 open source SOC to the FPGA board
- How to control a switch with stm32
- Design USB3.1 high-speed SD Card reader based on Genesys GL3224
- If you want to make the three-pole tube work in the amplification area, what is the idea? You need to calculate the static working point ib ic VCE three...
- How to save the bricks with the RVB2601 board
- 77Ghz single-chip millimeter wave sensor enables automatic parking
- What is the function of this circuit in ESP32_Audio_kit?