Output 1KHz and 500Hz audio signals to drive speakers
Use P1.0 to output 1KHz and 500Hz audio signals to drive the speaker as an alarm signal. The 1KHz signal is required to sound for 100ms and the 500Hz signal is required to sound for 200ms, alternately. P1.7 is connected to a switch for control. When the switch is closed, the alarm signal sounds, and when the switch is disconnected, the alarm signal stops. Write a program. 2. Circuit Schematic Diagram
Figure 4.6.1 3. Hardware connection on the system board (1. Connect the P1.0 port in the "MCU system" area to the SPK IN port in the "Audio amplifier module" area with a wire; (2. Connect an 8-ohm or 16-ohm speaker to the SPK OUT port in the "Audio amplifier module" area; (3. Connect the P1.7/RD port in the "MCU system" area to the K1 port in the "Four-way toggle switch" area with a wire; 4. Program design content (1. Signal generation method 500Hz signal period is 2ms, signal level is reversed once every 1ms, 1KHz signal period is 1ms, signal level is reversed once every 500us; 5. Program flowchart
Figure 4.6.2 6. Assembly source program FLAG BIT 00H ORG 00H START: JB P1.7,START JNB FLAG,NEXT MOV R2,#200 DV: CPL P1.0 LCALL DELY500 LCALL DELY500 DJNZ R2,DV CPL FLAG NEXT: MOV R2,#200 DV1: CPL P1.0 LCALL DELY500 DJNZ R2,DV1 CPL FLAG SJMP START DELY500: MOV R7,#250 LOOP: NOP DJNZ R7,LOOP RET END 7. C language source program #include
bit flag;
unsigned char count;
void dely500(void)
{
unsigned char i;
for(i=250;i>0;i--)
{
_nop_();
}
}
void main(void)
{
while(1)
{
if(P1_7==0)
{
for(count=200;count>0;count--)
{
P1_0=~P1_0;
dely500();
}
for(count=200;count>0;count--)
{
P1_0=~P1_0;
dely500();
dely500();
}
}
}
Previous article:Signal conditioning circuit for piezoresistive accelerometer
Next article:Delay circuit composed of operational amplifier
- Popular Resources
- Popular amplifiers
- Operational Amplifier Practical Reference Handbook (Edited by Liu Changsheng, Zhao Mingying, Liu Xu, etc.)
- MCU Principles and Interface Technology C51 Programming (Edited by Zhang Yigang)
- Electronic circuit diagram recognition, application and testing (Han Xuetao)
- Principles and Applications of Radio Frequency Identification (RFID)
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- 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
- Showing goods (1) - Various development boards
- Designing for Low Quiescent Current in Small Battery-Powered Devices
- About foreign masks
- 6657Statically configure serial port general interrupt in sys/bios
- Smart LED Octahedron
- [Lazy self-care fish tank control system] BLE_MESH fish tank light peripheral production
- Verilog001
- Direct imaging digital exposure technology "prints" the innovative future
- How to implement the logic of GD32E230 OAT? Is there any relevant code information?
- Microelectronic Circuit Design (4th Edition, English)