Function: ADC0832 realizes the output frequency of 50HZ sine wave
1, P0 port sends data,
2, P2.0 port is used as chip select signal
P21 is DAC start signal;
#include
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={ //sine wave data
128,130,132,135,137,139,141,144,146,148,150,152,155,157,159,161
163,165,168,170,172,174,176,178,180,182,184,186,188,190,192,194
196,198,200,201,203,205,207,209,210,212,214,215,217,219,220,222
223,225,226,227,229,230,232,233,234,235,237,238,239,240,24
1,242 243,244,245,246,247,247,248,249,250,250,251,252,252,253,253,254
254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255
255,255,255,254,254,254,253,253,252,252,251,250,250,249,24
8,247 247,246,245,244,243,242,241,240,239,238,237,235,234,233,232,230
229,227,226,225,223,222,220,219,217,215,214,212,210,209,207,205
203,201,200,198,196,194,192,190,188,186,184,182,180,178,17
6,174 172,170,168,165,163,161,159,157,155,152,150,148,146,144,141,139
137,135,132,130,128,126,124,121,119,117,115,112,110,108,106,104
101,99,97,95,93,91,88,86,84,82,80,78,76,74,72,70,68,66,64 ,
62,60,58 56,55,53,51,49,47,46,44,42,41,39,37,36,34,33,31,30,29,27,26,24,23,22
21,19,18,17,16,15,14,13,12,11,10,9,9,8,7,6,6,5,4,4,3,3,2,2,2,1,1
1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,4,4,5,6,6,7,8,9,9
,10,11,12 13,14,15,16,17,18,19,21,22,23,24,26,27,29,30,31,33,34,36,37,39,41,42
44,46,47,49,51,53,55,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86
88,91,93,95,97,99,101,104,106,108,110,112,115,117,119
,121,124,126,128 };
sbit cs=P2^0;
sbit dac=P2^1;
uchar num1,num2,num3,flag;
uchar aa,bb;
void delay();
void ad0832();
void main()
{
TMOD=0x01;
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
ET0=1;
EA=1;
TR0=1;
while(1)
{
if(flag==1)
{ i++;
if(table[i]=='\0')
i=0;
ad0832();
flag=0;
}
}
}
//===================
void delay(uint z)
{
uint x;
uchar y;
for(x=0;x
}
//-------------------------
void ad0809()
{
cs=0;
dac=1;
delay(1);
P0=table[i];
dac=0;
delay(10);
}
//=======================
void timer0() interrupt 1
{
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
flag=1;
}
Previous article:8-bit digital tube dynamically displays time, adjustable, the adjusted number flashes
Next article:LCD1602 clock displays time and date with alarm and can be adjusted cyclically
Recommended ReadingLatest update time:2024-11-17 08:45
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- Hand-drawn basic functional circuits
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Is it necessary to take a shower for 10 minutes after a burn?
- DCDC input capacitance waveform
- EEWORLD University Hall ---- The second stop of the ADI Road theme tour of Shijian: Instruments
- The features of the SCI module are as follows (these functions can be set through the corresponding registers)
- Shenzhen acoustic engineer job sharing, welcome to recommend and recommend yourself
- How to implement a multi-protocol communication solution that meets Industry 4.0?
- 【ST NUCLEO-H743ZI Review】 (4) - DCMI OV7620 Collection
- A very basic question, how to understand the reading timing diagram?
- Huang Jianxiang's crazy commentary was spoofed (audio)
- stm32f1 plays badaplle routine, modify the atomic routine, use vs1053 to decode audio, ucosII to do dual thread