51 MCU control beat generation example program
#include
sbit speaker=P3^7;
unsigned char Do=108;
unsigned char beat_H=(65536-62500)/256,beat_L()=(65536-62500)%256;
unsigned char tone_H=(65536-1908)/256,tone_L()=(65536-1908)%256;
char times,counts=5;
bit beat_flag;
//=====Timer0中断子程序======================
void tone_timer(void)interrupt 1
{TH0=tone_H;
TL0=tone_L;
speaker=~speaker;
}
main()
{char i;
IE=0x82;
TH0=beat_H;
TL0=beat_L;
for(i=0;i
beat_flag=0;
TR0=1;
if(beat_flag==0)
{speaker=~speaker;delay8us(tone[Do]);}
//===静音(1/4拍)=====================================
speaker=0;
times=2;
beat_flag=0;
TR0=1;
while(beat_flag=0);
}
}
//======================================================
void beat_timer(void)interrupt 1
{TH0=beat_H;
TL0=beat_L;
if(--times==0)
{beat_flag=1;
TR0=0;
}
}
//============================================
void delay8us(unsigned charx)
{unsigned char i,j;
for(i=0;i
}
Previous article:TLC1549 Driver
Next article:Timed interruption of 30-second countdown 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
- 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
- Loto Practice Tips (5) Detecting the power-on reset failure of the microcontroller with an oscilloscope
- Detailed explanation of EMC radiated emission test and conducted emission test
- 1
- RC Filtering
- 6ULL-BM140P Base Plate Manual
- Research and experience on vehicle control strategy for CAN bus application in pure electric vehicles
- After CC2541 is in master mode and searches for slaves to connect, the host can receive the data sent by the slave, but the slave cannot receive the data sent by the master?
- Review summary: Beetle ESP32-C3 free review
- Altiumdesigner 09 import Gerber file with fewer layers
- MSP430F1232 interrupt learning