Documentos de Académico
Documentos de Profesional
Documentos de Cultura
GV
GV
* File: proyecto_1.c
* Author: Alexis Rodriguez
*
* Created on 20 de agosto de 2019, 07:26 PM
*/
#include <xc.h>
#pragma config OSC = XT //SELECCION DE OSCILADOR
#pragma config PWRT = ON // POWER-UP TIMER ENABLE CONTADOR
#pragma config BOR = OFF
#pragma config WDT = OFF
#pragma config LVP = OFF
#define _XTAL_FREQ 4000000 //FRECUENCIA A LA QUE SE TRABAJA
#define ENABLE1 LA4
#define ENABLE2 LA5
void main(void)
{
configuracion();
while(1)
{
oper1=PORTD&0x0f;
oper2=(PORTD&0xf0)>>4;
operacion=PORTA&0x07;
resultado=ejecutar(operacion);
visualizar();
}
void configuracion(void)
{
TRISA= 0B00000111;
TRISB= 0x00;
TRISC= 0x00;
TRISD= 0xff;
ADCON1= 0x06;
}
switch (selector)
{
case 0 :
opcion=oper1+oper2;
break;
case 1:
opcion=oper1-oper2;
break;
case 2:
opcion=oper1*oper2;
break;
case 3:
opcion=oper1/oper2;
break;
case 4:
opcion=oper1&oper2;
break;
case 5:
opcion=oper1|oper2;
break;
case 6:
opcion=~(oper1|oper2);
break;
default:
opcion=oper1^oper2;
break;
}
return(opcion);
}
void visualizar(void)
{
char x;
while (a<1){
for (x=0;x<3;x++)
{
LATB=~numeros[oper1][x];
LATC=x; //PINES QUE VAN AL DECO
ENABLE1=1;
ENABLE2=0;
retardo();
}
for (x=0;x<3;x++)
{
LATB=~oper[operacion][x];
LATC=x+4; //PINES QUE VAN AL DECO
ENABLE1=1;
ENABLE2=0;
retardo();
}
for (x=0;x<3;x++)
{
LATB=~numeros[oper2][x];
LATC=x; //PINES QUE VAN AL DECO
ENABLE1=0;
ENABLE2=1;
retardo();
}
for (x=0;x<3;x++)
{
LATB=~0x12;
LATC=x; //PINES QUE VAN AL DECO
ENABLE1=0;
ENABLE2=1;
retardo();
}
a++;
}
while (a<1){
for (x=0;x<3;x++)
{
LATB=~numeros[(resultado&0xF0)>>4][x];
LATC=x+2; //PINES QUE VAN AL DECO
ENABLE1=1;
ENABLE2=0;
retardo();
}
for (x=0;x<3;x++)
{
LATB=~numeros[resultado&0x0F][x];
LATC=x+2; //PINES QUE VAN AL DECO
ENABLE1=0;
ENABLE2=1;
retardo();
}
a++;
}
}
for(x=0;x<3;x++)
{
LATB=numeros[oper1][x];
LATC=x;
ENABLE1=1;
ENABLE2=0;
retardo();
}
}