#include
//------------------------------------------------------------
// Use PIC16F887 chip to output 50k Hz square wave with 50% duty cycle
//------------------------------------------------------------
//系统配置
//__CONFIG(HS&PWRTEN&BOREN&PROTECT&WDTDIS);
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BORDIS & LVPDIS & IESODIS & FCMDIS);
//-------------中断服务程序------------------------------------
void interrupt isr()
{
if(TMR2IE==1&&TMR2IF==1)
{TMR2IF=0;
}
}
void SpwmInit()
{
OSCCON=0x7f;//using inner 8M osc
TRISC1=1;
TRISC2=1;
//TRISD = 0;
PR2=0x27;
CCP1CON=0x0f|0x00;
CCPR1L=0x14;
TMR2IF=0;
T2CON=0;
GIE=0;
TMR2IE=1;
PEIE=1;
TMR2ON=1;
}
main()
{ SpwmInit();
TRISC1=0;
TRISC2=0;
while(1)
{;}
}
Previous article:Implementing PIC16F5X asynchronous serial port with software
Next article:Key points and description of PIC24F EEPROM read and write interrupt event processing function
- 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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- TMS320F28335 IO Control Timing Operation
- What is red light plus green light?
- How to choose operating system for RK3399
- MYC-CZU3EG core board information
- Analyzing the temperature sensor sampling circuit
- STEVAL-IDB008V2 board connected to BlueNRG Navigator cannot download firmware
- 【DFRobot motor driver】+Received DFRobot Arduino driver board
- ART-Pi evaluates the GUI design framework in VNC mode,
- About the Common Program Framework of MSP430 MCU
- About Freescale programming environment KDS3.0 software issues