#include
//stdio.h, string.h are used for printf function prototype
#include
#include
sbit AD_CS = P1^2;
sbit AD_WR = P1^0;
sbit AD_RD = P1^1;
sbit AD_PORT = P0;
/**************************************
*
* Enable ADC
*
***************************************/
void AdcStart(void)
{
AD_CS = 0;
_nop_();
AD_WR = 0;
_nop_();
AD_WR = 1;
_nop_();
AD_CS = 1;
_nop_();
}
/**************************************
*
* Read ADC value
*
***************************************/
int AdcRead(void)
{
int temp;
AD_PORT = 0xFF; // Write high to PORT port before MCU reads AD value
AD_CS = 0;
_nop_();
AD_RD = 0;
_nop_();
_nop_();
_nop_();
temp = P0;
_nop_();
AD_RD = 1;
_nop_();
AD_CS = 1;
_nop_();
return temp;
}
Previous article:C51 Timer Counter
Next article:C51 serial port sending and receiving, printf, receiving character string
- 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
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- FPGA implementation of terrestrial digital television symbol and carrier synchronization.pdf
- Classic: MSP430 microcontroller enters low power mode program code
- X-NUCLEO-IKS01A3 sensor test based on STM32F401RE development board 3D acceleration LIS2DW12 sensor test...
- I would like to ask if the 8255A chip can only select one port at a time. After defining the address for the port, such as Q8255A XBYTE...
- Power supplies with digital control
- Please advise, brothers.
- One year's work equals three years' work? TSMC engineer shows off 2.5 million yuan bonus
- Evaluation summary: Mil based on NXP's first NPU kit MYC-JX8MPQ
- How to choose a suitable water level sensor?
- Can someone help me think of a microcontroller project?