Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _XTAL_FREQ 4000000
- #include <pic16f873a.h>
- #include <xc.h>
- #include <stdio.h>
- #include <stdlib.h>
- void interrupt Interrupt_Handlers(void){
- if(INTCONbits.T0IF == 1){
- INTCONbits.T0IF = 0;
- }
- }
- int main(int argc, char** argv) {
- INTCONbits.GIE = 1;
- INTCONbits.PEIE = 1;
- INTCONbits.T0IE = 1;
- TRISCbits.TRISC2 = 0;
- // Modo comparacion
- T1CONbits.T1CKPS = 0b11; // Preescaler 1:8
- T1CONbits.T1OSCEN = 0; // No usamos el timer como oscilador
- T1CONbits.TMR1CS = 0; // Contamos con el clock interno
- T1CONbits.TMR1ON = 1; // Encendemos el timer
- CCP1CONbits.CCP1M = 0b1000; // CCP1 como comparacion
- CCPR1 = 65535;
- TMR1 = 0;
- while(1){
- if(PIR1bits.CCP1IF == 1){
- PIR1bits.CCP1IF = 0;
- PORTCbits.RC2 = 0;
- TMR1 = 0;
- }
- }
- return (EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement