#include <16F876A.h>
#device ADC=10
#fuses NOWDT, HS, PUT, PROTECT, NOBROWNOUT, NOLVP, NOCPD
#use delay(clock=20000000)
#ZERO_RAM
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#byte tris_porta = 0x85
#byte tris_portb = 0x86
#byte tris_portc = 0x87
#byte porta = 0x05
#byte portb = 0x06
#byte portc = 0x07
#define ERA_595 PIN_A0
#define BTN_MODO PIN_B0
#define DATO_595 PIN_B1
#define CLK_595 PIN_B2
#define STH_595 PIN_B3
#define BTN_START PIN_C0
#define TX PIN_C6
#define RX PIN_C7
#use rs232(baud=9600,parity=N,xmit=TX,rcv=RX,bits=8,stream=PORT1)
#define cargar output_high(STH_595); delay_cycles(1); output_low(STH_595);
#define clk output_high(CLK_595); delay_cycles(1); output_low(CLK_595);
/*********************************** 0 1 2 3 4 5 6 7 8 9 - F ****/
const unsigned int8 digi7S[2][13]={{0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xEF,0xC0,0xF1,0x80},
{0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x40,0x71,0x00}};
int1 dt=false;
unsigned int8 mil_seg=0, digito=0x10, conta1=0;
unsigned char modo=0;
static unsigned int8 Display[8]={0,0,0,0,0,0,0,0};
unsigned long p=0;
////////////////////////////////////////////////////////////////////////
// DESPLAZAMIENTO 4094 Y PARALELO ULN2803
////////////////////////////////////////////////////////////////////////
void write_REG(int8 dato1, int8 dato2) {
int16 total;
total = (dato2*0x100) | dato1;
output_low(STH_595); output_low(CLK_595);
for(int8 i=0;i<16;i++){
output_bit(DATO_595,shift_left(&total,2,0)); //MSB first
clk;
}
cargar;
}