The simulation circuit diagram is the same as the circuit diagram for generating sawtooth wave .
The program is timed using interrupts.
The C program is as follows:
#include
sbit CS0=P3^0;
sbit WR0=P3^1;
bit flag=0;
unsigned char i=0;
unsigned char code sin_num[]={
0,0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2,
2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21,
22, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37,
38, 39, 40, 41, 42, 44, 45, 46, 47, 49, 50, 51, 52, 54, 55, 56,
57, 59, 60, 61, 63, 64, 66, 67, 68, 70, 71, 73, 74, 75, 77, 78,
80, 81, 83, 84, 86, 87, 89, 90, 92, 93, 95, 96, 98, 99, 101,102,
104, 106, 107, 109, 110, 112, 113, 115, 116, 118, 120, 121, 123, 124, 126, 128,
129, 131, 132, 134, 135, 137, 139, 140, 142, 143, 145, 146, 148, 149, 151, 153,
154, 156, 157, 159, 160, 162, 163, 165, 166, 168, 169, 171, 172, 174, 175, 177,
178, 180, 181, 182, 184, 185, 187, 188, 189, 191, 192, 194, 195, 196, 198, 199,
200, 201, 203, 204, 205, 206, 208, 209, 210, 211, 213, 214, 215, 216, 217, 218,
219, 220, 221, 223, 224, 225, 226, 227, 228, 229, 230, 230, 231, 232, 233, 234,
235, 236, 237, 237, 238, 239, 240, 240, 241, 242, 243, 243, 244, 245, 245, 246,
246, 247, 247, 248, 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253,
253, 253, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255
}; //This is the sampling of the rising half cycle of the sine wave
void sinn() interrupt 1
{
if(flag==0)
{
P2=sin_num[i++];
if(i==0){flag=1;i=255;}
}
else
{
P2=sin_num[i--];
if(i==255){flag=0;i=0;}
}
}
main()
{
TMOD=0X01; //Counter T0, self-start, timing, mode 1
TH0=0xff; //Select counter T0
TL0=0x00;
IT0=1; //Set interrupt trigger mode, falling edge
EA=1; //Open interrupt
EX0=1; //External interrupt INT0, to expand the waveform, you can press the key to adjust the waveform
ET0=1; //External interrupt INT0, to expand the waveform, you can press the key to adjust the waveform
IP=0X01; //Keyboard interrupt level high
TR0=1;
CS0=0;//dac0832 is in direct mode
WR0=0;
while(1)
{
}
}
Previous article:51proteus simulation: generate square wave, sine wave, sawtooth wave and triangle wave
Next article:51proteus simulation: generating sawtooth waves
Recommended ReadingLatest update time:2024-11-17 03:03
- Popular Resources
- Popular amplifiers
- Siemens PLC Programming Technology and Application Cases (Edited by Liu Zhenquan, Wang Hanzhi, Yang Kun, etc.)
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- Implementing a Deep Learning Framework with Python (Zhang Juefei, Chen Zhen)
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
- 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?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- SAM-L10-L11 series Questions and Answers
- EEWORLD University Hall----RMB settlement, VAT invoice issuance and various payment methods
- [CB5654 Intelligent Voice Development Board Review] Comparison of Voice Recognition Development Boards
- C2000 Delfino MCU F28379D LaunchPad Development Kit
- [HPM-DIY] HPM SDK updated to 0.13 SD card reading and writing performance greatly improved
- Radio communication equipment manufacturing
- How to learn hardware circuits well
- The difference between grounding and not grounding the input end of the differential amplifier circuit
- FAQ_Huawei smartphones cannot search for BLE devices based on Bluencg-132
- TM4C 129 CAN communication