#include <16F84A.h>
#INCLUDE <MATH.H>
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#use delay(clock=10000000)
#BYTE PORTA = 0x05
#BYTE PORTB = 0x06
#BYTE PORTA_TRIS = 0x85
#BYTE PORTB_TRIS = 0x86
#DEFINE RDD_DATA PIN_B7
#DEFINE RDD_CLOCK PIN_B6
#DEFINE EEPROM_SCL PIN_A2
#DEFINE EEPROM_SDA PIN_A3
//
void fConfigurar_puertos(void);
void fRDD_send_data0(void);
void fRDD_send_data1(void);
int8 ds=100;
int8 d=ds/100;
//--------------------------------------------------
//Main----------------------------------------------
//--------------------------------------------------
void main(){
int8 i,j;
fConfigurar_puertos();
output_low(RDD_CLOCK); //RELOJ = Bajo
while (TRUE){
PORTB = 0b110; //Filas
//*********************//Generador Clock Data//
for (i=0;i<3;i++) { fRDD_send_data0();
for (j=0;j<4;j++) {
fRDD_send_data1();
}
output_low(RDD_CLOCK);
//*********************//Generador Clock Data//
PORTB = (PORTB <<1) +1; //Filas
}
}//Fin while
}//Fin main
//--------------------------------------------------
//- FUNCIONES-
//--------------------------------------------------
void fConfigurar_puertos(void){
PORTA_TRIS = 0b00001100; //1=ENTRADA, 0=SALIDA
PORTB_TRIS = 0b00000000; //1=ENTRADA, 0=SALIDA
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
port_b_pullups(TRUE);
}
void fRDD_send_data0(void){
output_low(RDD_DATA);
delay_ms(d);
output_high(RDD_CLOCK);
delay_ms(ds);
output_high(RDD_DATA);
output_low(RDD_CLOCK);
delay_ms(d);
output_high(RDD_CLOCK);
delay_ms(ds);
}
void fRDD_send_data1(void){
output_low(RDD_CLOCK);
delay_ms(d);
output_high(RDD_CLOCK);
delay_ms(ds);
}