Hola amigos estoy realizando un circuito de reloj alarma con un pic 18f4550, ds1307 y mostrarlos en un display la coa es que yo he visto muchos circuitos pero todos osn en lcd y de paso los que son con display de 7 segmentos me dicen que debo usar la multiplexacion cosa que es lo que estoy implementando, estoy usando la libreria ds1307 que contiene como poner hora, como leerla y cosas asi. Mi duda es que ya tengo mi codigo pero no se porque el valor de segundos me va tan lento no se si es por mi codigo o por mi circuito hecho proteus. Adjunto mi codigo y la simulacion en proteus y no entiendo el cristal que le pongo al ds1307 no me hace efecto. En proteus no tengo el uso de los transitores yo se que al ponerlo en practica lo necesito pero mientras tanto lo he dejado sin transitores. Agradeceria su ayuda porque no entiendoo porque lo minutos estan tan lentos
#include "C:\Users\VictorXZ\Documents\Microprocesadores\paper2\reloj.h"
#include "C:\Program Files (x86)\PICC\Drivers\tones.c"
#include "C:\Program Files (x86)\PICC\Drivers\ds1307.c"
//#define RTC_SDA PIN_B0
//#define RTC_SCL PIN_B1
#define USE_INTERRUPTS 1
#define DIG_1 PIN_B2
#define DIG_2 PIN_B3
#define DIG_3 PIN_B4
#define DIG_4 PIN_B5
#define DIG_5 PIN_E0
#define DIG_6 PIN_E1
#define DIG_7 PIN_B6
#define DIG_8 PIN_B7
#define DIG_9 PIN_C0
#define DIG_10 PIN_B7
#define DIG_11 PIN_C0
#define DIG_12 PIN_C1
#define DIG_13 PIN_C2
#define DIG_14 PIN_E2
#define DIG_15 PIN_D7
INT digitos[16]={0b00111111,0b00000110,0b001011011,0b01001111 ,0b01100110,0b01101101, 0b01111101, 0b00000111, 0b01111111, 0b01101111,0b01110111 ,0b01111100,0b00111001, 0b01011110, 0b01111001, 0b01110001 };
Long int delay_1=10;
int1 dump;
int1 kdump;
int alta=0;
int baja=0;
int minuto;
byte sec,min, hrs, day ,month, year, dow;
void leer_hora_fecha(void){
byte temp;
byte retval;
ds1307_get_date(day,month,year,dow);
ds1307_get_time(hrs,min,sec);
sec=ds1307_bin2bcd(sec);alta = (sec & 0xF0) >> 4;baja = sec & 0x0F; //Convierto el numero en bcd y luego lo divido en 2 partes de 4 bits para cada par display
output_high(DIG_1);output_high(DIG_2);output_high(DIG_3);output_high(DIG_4);output_high(DIG_5); //Con esto logro que se apaguen todos los display que pienso usa
output_high(DIG_6);output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);output_high(DIG_10);
output_high(DIG_11);output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
output_d(digitos[alta]);
output_low(DIG_1);
output_high(DIG_2);output_high(DIG_3);output_high(DIG_4);output_high(DIG_5);output_high(DIG_6);
output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);;output_high(DIG_10);output_high(DIG_11);
output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
delay_ms(delay_1);
output_high(DIG_1);output_high(DIG_2);output_high(DIG_3);output_high(DIG_4);output_high(DIG_5);
output_high(DIG_6);output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);output_high(DIG_10);
output_high(DIG_11);output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
output_d(digitos[baja]);
output_low(DIG_2);
output_high(DIG_1);output_high(DIG_3);output_high(DIG_4);output_high(DIG_5);output_high(DIG_6);
output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);output_high(DIG_10);output_high(DIG_11);
output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
delay_ms(delay_1);
output_high(DIG_1);output_high(DIG_2);output_high(DIG_3);output_high(DIG_4);output_high(DIG_5);
output_high(DIG_6);output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);output_high(DIG_10);
output_high(DIG_11);output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
min=ds1307_bin2bcd(min);alta = (min & 0xF0) >> 4;baja = min & 0x0F; //Convierto el numero en bcd y luego lo divido en 2 partes de 4 bits para cada par display
output_d(digitos[alta]);
output_low(DIG_3);
output_high(DIG_1);output_high(DIG_2);output_high(DIG_4);output_high(DIG_5);output_high(DIG_6);
output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);output_high(DIG_10);output_high(DIG_11);
output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
delay_ms(delay_1);
output_high(DIG_1);output_high(DIG_2);output_high(DIG_3);output_high(DIG_4);output_high(DIG_5);
output_high(DIG_6);output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);output_high(DIG_10);
output_high(DIG_11);output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
output_d(digitos[baja]);
output_low(DIG_4);
output_high(DIG_1);output_high(DIG_2);output_high(DIG_3);output_high(DIG_5);output_high(DIG_6);
output_high(DIG_7);output_high(DIG_8);output_high(DIG_9);output_high(DIG_10);output_high(DIG_11);
output_high(DIG_12);output_high(DIG_13);output_high(DIG_14);output_high(DIG_15);
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_spi2(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// ext_int_edge(2,H_TO_L);
// flanco=0;
// enable_interrupts(int_ext2);
// enable_interrupts(int_rda);
//enable_interrupts(global);
// TODO: USER CODE!!
ds1307_init(DS1307_OUT_ENABLED | DS1307_OUT_1_HZ);// inicializo el ds1307
ds1307_set_date_time(12,12,1991,0,2,39,2);//poner la hora al reloj
dump = 0;
kdump= 1;
do{
if(dump==1){
if((dump!=kdump)&&dump==1){
kdump=dump;
}
delay_ms(1);
leer_hora_fecha();
}else{
if((dump!=kdump)&&dump==0){
dump= kdump;
}
}
} while (TRUE);
}