/*******************************************************************
Experiment name: Generate sine wave demonstration experiment
device: ATmega16L
crystal oscillator: external 12M
wiring method:
1. PD5 connects to low-pass filter input
2. Use oscilloscope to measure its output waveform
******************************************************************/
#include
#include
#include
#pragma interrupt_handler timer1:9
char auc_SinParam[128]={//128-point sine wave sample value
128,134,140,147,153,159,165,171,177,182,188,193,198,204,208,213,
218,222,226,230,233,237,240,242,245,247,249,251,252,253,254,254,
254,254,253,252,251,250,248,246,244,241,238,235,232,228,2 24,220,
215,211,206,201,196,191,185,179,174,168,162,156,150,144,137,131,
125,119,112,106,100,94,88,82,77,71,65,60,55,50,45,41,
36,32,28,24,21,18,15,12,10,8,6,5,4,3,2,2,
2,2,3,4,5,7,9,11,14,16,19,23,26,30,34,38,
43,48,52,57,63,68,74,79,85,91,97,103,109,116,122,128
};
char x=0;
//T/C1 overflow interrupt service
void timer1(void)
{
x=x+1;
if (x>128)
x=0;
OCR1A=auc_SinParam[x];//auc_SinParam[x];//Sampling point pointer to compare match register
}
void main(void)
{
DDRD=0xff;//PB3 output mode, as OC0 output PWM wave
TIMSK=0x04; //Interrupt mask bit, no interrupt is enabled
TIFR=0; //Interrupt flag
TCCR1A=0xA1; //Open PWM
TCCR1B=0x09;//System clock
SREG=0x80; //Open global interrupt
OCR1A=128;//auc_SinParam[x];
}
Previous article:ATmega16 read and write 24Cxx program
Next article:ATmega16L serial communication program
Recommended ReadingLatest update time:2024-11-16 13:56
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Intelligent Control Technology of Permanent Magnet Synchronous Motor (Written by Wang Jun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【XMC4800 Relax EtherCAT Kit Review】+ Getting started with DAVE, simple application of ADC module
- Half a year has passed, let’s share what we have gained in EEWORLD!
- MSP430F5529 generates PWM waves with CCS
- FPGA Multiplier
- Quartus2 simulation can not produce waveform
- 2. GD32L233C-START environment construction
- AI automatically generates Spring Festival couplets to warm up for FZ5
- STM32F407VG mount SD card
- Four-bit parallel 9012 drive digital tube
- Design of Industrial Temperature Transmitter