The compiler used is PICC9.83
You can try it, but you must turn off AD.
//***************************************************
//__________________
// VDD-| 1 14 |-VSS
// Motor GP5-| 2 13 |-GP0/AN0/DAT LED
// AN3/GP4-| 3 12 |-GP1/AN1/CLK
//GP3/RMCLR--| 4 11 |-GP2/AN2
// |________________ |
//16F675
//***************************************************
#include #define uchar unsigned char #define uint unsigned int #ifndef OPEN #define OPEN 1 #endif #ifndef OFF #define OFF 0 #endif #define SET 1 #define CLEAR 0 #define TRUE 1 #define FALSE 0 __CONFIG(FOSC_EXTRCIO & WDTE_OFF & MCLRE_OFF & BOREN_OFF & CP_OFF & PWRTE_ON); //Internal RC watchdog is turned off GP3 is IO code is not protected //#pragma config BOREN = OFF, CPD = OFF, FOSC = XT, MCLRE = OFF, WDTE = OFF, CP = OFF, PWRTE = OFF #define KEY GPIO3 #define LED GPIO0 #define BEEP GPIO1 #define SCR GPIO5 #define GHG GPIO4 /*********Program declaration****************/ void InitAPP(void); //void ScanKey(); void InitAPP() { /* Comment out if using simulator, ICD2, or ICE2000 #asm //Load Factory Calibration Value Into OSCCAL call 0x3FF bsf_STATUS,5 movwf _OSCCAL #endasm */ TRISIO=0x00; //Set All I/O's As OUT VRCON = 0; //Reference voltage power off CMCON = 0x07; // configure comparator inputs as digital I/O ANSEL = 0; // configure A/D inputs as digital I/O ADON = 0; GIE = 1; //Enable All Interrupts //RAPU=0; //Pull-up always enabled // WPUA5=1; //RA5 enable // RAIE=1; IOCB5=1; //Pin interrupt enable } /*********Timer initialization***************/ void TimeInt() { OPTION_REG &= 0x80; // TMR0 = 0x14; // 250uS T0IE = 1; //Timer0 Overflow Interrupt Enabled T0IF = 0; //Clear Timer0 Overflow Interrupt Flag } //*************************************************************************** //Isr() - Interrupt Service Routine // - Timer0 Overflow & GP3 Pin Change Are Used //*************************************************************************** void interrupt Isr() { static uint count; if ( (T0IE & T0IF) == 1) //If A Timer0 Interrupt, Then { TMR0 = 0x14; if(++count==40) { count=0; LED=~LED; } T0IF = 0; //Clear Timer0 Interrupt Flag } /* else if ( (GPIE & GPIF) == SET) //If A GP3 Pin-Change Interrupt { if(GHG==0) { SCR = 1; // Turn off the motor BEEP=0; //Turn on the buzzer } else if(GHG==1) { SCR=0; //Turn on the motor BEEP=1; //Turn off the buzzer } GPIF=0; } else if ( (INTE & INTF) == SET) //If A GP2/INT External Intrrupt { } else if ( PEIE == SET) //If Peripheral Interrupts Enabled, Check Peripheral { //Interrupts if ( (EEIE & EEIF) == SET) //If A EEPROM Interrupt { } else if ( (ADIE & ADIF) == SET) //If AA/D Converter Interrupt { } else if ( (CMIE & CMIF) == SET) //If A Comparator Interrupt { } else if ( (TMR1IE & TMR1IF) == SET) //If A Timer1 Interrupt { } } ***************************/ } //********************************************************************************* //Main() - Main Routine //********************************************************************************* void main() { InitAPP(); TimeInt(); while(1) { } }
Previous article:A simple SPI applet for PIC microcontroller
Next article:HC-SR04 ultrasonic module 51+PIC microcontroller routine
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- The experience of debugging L-band RF power amplifier is in "2019.1.1" for your reference
- 2021 ON Semiconductor Avnet RSL10 Bluetooth SoC Development and Design Competition 4th Post (Bluetooth Current)
- MSP430FR5969 Remote Upgrade
- Circuit help, how do you analyze this circuit?
- EEWORLD University - Designing Wide Input DC/DC Converters for Thermostat Applications
- Win a JD.com card! Check in at Infineon's new SiC MOSFET pop-up store
- System Antenna Design Method Based on Characteristic Mode Theory
- Active crystal oscillator waveform problem
- Multi-cell lithium battery charging management solution-TPS54201 application in sweeping robot
- RT-Thread uses printf or rt_kprintf function for serial port printing