Estimados amigos foreros, tengo el siguiente problema con un temporizador he buscado la solución en el foro encontrando algunos ejemplos pero no me funciona la interrupción cuando las secuencias están funcionando. La idea principal es que se reinicie el ciclo o secuencia cuando esta este funcionando.
#include <16F628A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES RESERVED //Used to set the reserved FUSE bits
#byte portb=0x06
#byte trisb=0x86
#byte porta=0x05
#byte trisa=0x85
#use fast_io(b)
int FLAG_INT_EXT=0;
#use delay(clock=4000000)
#define TEST_SISTEMA PIN_A0
#define LUCES PIN_B3
#define TIMBRE PIN_B4
#define TIMBRE_TRANSITO PIN_B5
#define LUZ_TRANSITO PIN_B6
#define ANEXO_1 PIN_B7
void Secuencia_1(void);
void Secuencia_2(void);
void Segundos(int);
void Minutos(int);
void Delay10KTCYx ( unsigned char unit );
#int_EXT
void esterna(void)
{
FLAG_INT_EXT=1;
delay_ms(200);
}
void main()
{
trisb=0b00000001;
trisa=0b00000001;
portb=0;
enable_interrupts(INT_EXT);
ext_int_edge(H_TO_L); //doy las indicaciones que vienen desde un sensor que entra con un opto al pic de alto a bajo
enable_interrupts(GLOBAL);
while(TRUE){
// ******** Procesos que se hacen si ocurre una int. ******************
if(FLAG_INT_EXT==1){
FLAG_INT_EXT=0; /* actualizo el flag para una nueva interrupcion */
Secuencia_1();
}
if(input(TEST_SISTEMA)==1){
Secuencia_2();
delay_ms(200);
}
// ******************** espera la int. **************************
while(FLAG_INT_EXT==0);
}
}
//tiempos para las salidas
void Segundos(int seg)
{
int i;
for(i=0;i<seg;i++)
{
delay_ms(1000); //100 ms cada 1 10KTCYx por tanto 1 seg
}
}
void Minutos(int min)
{
int i;
for(i=0;i<min;i++)
{
Segundos(60);
}
}
//temporizador de salidas
void Secuencia_1(void)
{
//-------------Limpia salidas-----------------------------
output_low(LUCES);
output_low(TIMBRE);
output_low(TIMBRE_TRANSITO);
output_low(LUZ_TRANSITO);
output_low(ANEXO_1);
output_high(LUCES);
output_high(TIMBRE);
output_high(ANEXO_1);
Segundos(5);
//-------------5 segundos transcurridos--------------------
output_low(TIMBRE); //RB6 primer ciclo
output_low(ANEXO_1);
Segundos(7);
//-------------12 segundos transcurridos--------------------
output_high(TIMBRE_TRANSITO);
output_high(LUZ_TRANSITO);
Segundos(7);
//-------------20 segundos transcurridos--------------------
output_low(TIMBRE_TRANSITO);
Minutos(1);
output_low(LUCES);
output_low(LUZ_TRANSITO);
}
void Secuencia_2(void)
{
{
//-------------Limpia salidas-----------------------------
output_low(LUCES);
output_low(TIMBRE);
output_low(TIMBRE_TRANSITO);
output_low(LUZ_TRANSITO);
output_low(ANEXO_1);
output_high(LUCES);
output_high(TIMBRE);
output_high(ANEXO_1);
Segundos(2);
//-------------5 segundos transcurridos--------------------
output_low(TIMBRE); //RB6 primer ciclo
output_low(ANEXO_1);
Segundos(3);
//-------------12 segundos transcurridos--------------------
output_high(TIMBRE_TRANSITO);
output_high(LUZ_TRANSITO);
Segundos(4);
//-------------20 segundos transcurridos--------------------
output_low(TIMBRE_TRANSITO);
Minutos(2);
output_low(LUCES);
output_low(LUZ_TRANSITO);
}
}
cuando compilo este codigo me da el siguiente Warning
Warning 216 "main.c" Line 155(0,1): Interrupts disabled during call to prevent re-entrancy: (@delay_ms1)
por lo que he leído debo asignar una flag lo hice pero nada igual sigo con los problemas, espero encontrar una ayudita, GRACIAS...