Você está na página 1de 3

/*

* File: ENCODER PARA PIC 16F84A

* Author: LUIS ARBEY CORREDOR CHAVES

* Created on 29 de mayo de 2019, 07:43 PM

*/

#include <stdio.h>

#include <stdlib.h>

#include <xc.h> // Librería XC8

#define _XTAL_FREQ 4000000 // Indicamos a que frecuencia de reloj esta funcionando el micro

// PIC16F648A Configuration Bit Settings

#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on
RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)

#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)

#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)

#pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin
function is digital input, MCLR internally tied to VDD)

#pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled)

#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital
I/O function, HV on MCLR must be used for programming)

#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code
protection off)

#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)

//Etiquetas para las salidas

//Renombramos los pines para que sea mas facil acceder a ellos

#define FASE_A PORTBbits.RB0 //Nombro las entradas del encoder


#define FASE_B PORTBbits.RB1 //Nombro las entradas del encoder

//Etiquetas globales, para hacer el codigo mas comprensible

#define Encender 1

#define Apagar 0

#define Allinput 0xff

#define AllClear 0x00

//Variables generales
https://www.xvideos.com/video24244431/spectacular_vintage_orgy_for_unleashed_and_pervers
e_sex

unsigned char count;

unsigned char giro;

//Declaracion de prototipos

void MCU_Delayms(unsigned int t);

// FUNCION PRINCIPAL

void main () {

TRISB = 0; // Puerto B como salidas

PORTB = 0;

// Configuración del timer & interrupcion

TMR0 = 0;

INTCONbits.TMR0IE = 1;

INTCONbits.GIE = 1;

OPTION_REGbits.PS0 = 1;

OPTION_REGbits.PS1 = 1;

OPTION_REGbits.PS2 = 1;
OPTION_REGbits.PSA = 0;

OPTION_REGbits.T0CS = 0;

// Bucle infinito

while (1){

if (cuenta == 10){

LED ^= 1;

cuenta = 0;

//Rutina para generar retardos en milisegundos

void MCU_Delayms(unsigned int t){

unsigned int acc;

//Se repite mientras acc sea menos a t

for(acc=0; acc<t; acc++){

__delay_ms(1); //Retardo de 1 milisegundo

Você também pode gostar