#include <16F877A.h>
#FUSES NOWDT //Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=4000000)
#priority psp,rtcc
int8 j;
int8 i;
int8 valor;
int8 salida[4]={0x0A,0x0A,0x0A,0x0A};
Const int8 Numeros[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x00,0x00,0x00,0x20,0x00,0x00};
/*
Numero\Equi B7 B6 B5 B4 B3 B2 B1 B0 | B0 ---
0 0 0 1 1 1 1 1 1 0x3F | B6 B1 | |
1 0 0 0 0 0 1 1 0 0x06 | B5 ---
2 0 1 0 1 1 0 1 1 0x5B | B4 B2 | |
3 0 1 0 0 1 1 1 1 0x4F | B3 ---
4 0 1 1 0 0 1 1 0 0x66 |
5 0 1 1 0 1 1 0 1 0x6D
6 0 1 1 1 1 1 0 1 0x7D
7 0 0 0 0 0 1 1 1 0x07
8 0 1 1 1 1 1 1 1 0x7F
9 0 1 1 0 1 1 1 1 0x6F
A 0 0 0 0 0 0 0 0 0x00
*/
//*************************************************************************
//*************************************************************************
#INT_PSP //Interrupcion del Parallel Slave Port
void Adquierelo()
{
disable_interrupts(GLOBAL);
valor=psp_data;
switch(Valor&0x0F)
{
case 0x00:
salida[3]=(valor&0xF0)/0x10;
break;
case 0x04:
salida[2]=(valor&0xF0)/0x10;
break;
case 0x08:
salida[1]=(valor&0xF0)/0x10;
break;
case 0x0C:
salida[0]=(valor&0xF0)/0x10;
break;
case 0x0F:
salida[0]=0x0A;
salida[1]=0x0A;
salida[2]=0x0A;
salida[3]=0x0A;
break;
}
enable_interrupts(GLOBAL);
}
//*************************************************************************
#int_TIMER0
void muestralo()
{
Output_B(0x00);
switch(i)
{
case 0:
output_high(PIN_A0);
output_low(PIN_A1);
output_low(PIN_A2);
output_low(PIN_A3);
output_B(Numeros[salida[0]]);
break;
case 1:
output_low(PIN_A0);
output_high(PIN_A1);
output_low(PIN_A2);
output_low(PIN_A3);
output_B(Numeros[salida[1]]);
break;
case 2:
output_low(PIN_A0);
output_low(PIN_A1);
output_high(PIN_A2);
output_low(PIN_A3);
output_B(Numeros[salida[2]]);
break;
case 3:
output_low(PIN_A0);
output_low(PIN_A1);
output_low(PIN_A2);
output_high(PIN_A3);
output_B(Numeros[salida[3]]);
}
i++;
if(i>3)
i=0;
set_timer0(0xE0);
}
//============================================================================
//////////////////////////////////////////////////////////////////////////////
void main()
{
for(j=1;j<7;j++)
{
output_high(PIN_B7);
delay_ms(100);
output_low(PIN_B7);
delay_ms(100);
}
setup_psp(PSP_ENABLED);
setup_adc_ports(NO_ANALOGS);
enable_interrupts(GLOBAL);
enable_interrupts(INT_PSP);
enable_interrupts(INT_TIMER0);
output_low(PIN_B7);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_128);
port_b_pullups(TRUE);
set_timer0(255);
while(1)
{
;
}
}