void main(void)
{
//##############################################################################
//##############################################################################
//##############################################################################
/*****************************
******** T I M E R 1 ********
*****************************/
T1CONbits.TMR1CS = 0; // Timer1 Clock Source - 0 Internal clock (FOSC/4) //******** esta es la 1939 ********
T1CONbits.T1CKPS1 = 1; // prescaler
T1CONbits.T1CKPS0 = 1; // 1:8
TMR1H = VALOR_TMR1H; // 3036
TMR1L = VALOR_TMR1L; // 500 ms
T1CONbits.TMR1ON = 0; // Timer1 On bit
PIE1bits.TMR1IE = 1; // TMR1 Overflow Interrupt Enable bit
/*********************
*** P U E R T O S ***
*********************/
/**** PORTD I/O ****/
TRISEbits.PSPMODE = 0; // PORTD functions in general purpose I/O mode
/**** PORTE I/O ****/
TRISEbits.TRISE2 = 0; // Output
TRISEbits.TRISE1 = 0; // Output
TRISEbits.TRISE0 = 0; // Output
/**** PORTA / PORTE I/O ****/
ADCON1bits.PCFG3 = 0; // RA5:RA0 y RE2:RE0 Digital
ADCON1bits.PCFG2 = 1; // RA5:RA0 y RE2:RE0 Digital
ADCON1bits.PCFG1 = 1; // RA5:RA0 y RE2:RE0 Digital
ADCON1bits.PCFG0 = 1; // RA5:RA0 y RE2:RE0 Digital
TRISA = 0b00000000; // Salida
TRISC = 0b00000000; // Salida
TRISD = 0b00000000; // Salida
TRISE = 0b00000000; // Salida
PORTA = 0b00000000;
PORTB = 0b00000000;
PORTC = 0b00000000;
PORTD = 0b00000000; // puerto LCD
PORTE = 0b00000000;
//##############################################################################
//##############################################################################
//##############################################################################
// configurar_pic(); // lo de arriba estaba en esta funcion
CD4094_LCD_inicializar();
//##############################################################################
//##############################################################################
//##############################################################################
LCD_ENCENDER = 1;
// inicializa la estructura
for ( char cnt = 0; cnt < 10; cnt++ )
{
du[cnt].iniciar = 0;
du[cnt].seleccionada = 0;
du[cnt].retardo_seg = 0;
du[cnt].tiempo_seg = 0;
du[cnt].cant_fichas_ins = 0;
}
du[0].seleccionada = 1; // establece la primera como seleccionada
contador_interrupciones_timer1 = 0;
cronometro_refrigeracion = INTERVALO_REFRIGERACION_SEG;
modo_programacion = 0; // 0 indica que no esta en el modo programacion
//##############################################################################
//##############################################################################
//##############################################################################
// inicializar_valores(); // lo de arriba estaba en esta funcion
RETARDO_500_MS;
mostrar_datos_inicio();
//##############################################################################
//##############################################################################
//##############################################################################
INTCONbits.RBIF = 1;
INTCONbits.INTF = 1;
/**** INTERRUPCIONES ****/
INTCONbits.PEIE = 1; // Enables all unmasked peripheral interrupts
INTCONbits.RBIE = 1; // Enables the RB port change interrupt
// PORTB pull-ups are enabled by individual port latch values
OPTION_REGbits.nRBPU = 1;
// Interrupt on rising (creciente) edge of RB0/INT pin
OPTION_REGbits.INTEDG = 1;
INTCONbits.RBIF = 0;
INTCONbits.INTF = 0;
INTCONbits.GIE = 1; // Enables all unmasked interrupts
T1CONbits.TMR1ON = 1; // Timer1 On bit
//##############################################################################
//##############################################################################
//##############################################################################
// activar_interrupciones_PORTB_TIMER(); // lo de arriba estaba en esta funcion
PORTA = 0b00000000;
PORTC = 0b00000000;
mostrar_en_display( LCD_EQUIPO_FUNCIONA_OK, 0 );
emitir_sonido_general();
while ( 1 )
{
;
}
}