Hello;
This is my program; and it is not work.
the main Idea fo my program that; when any input of A0,A1,A2 change.
the PIC 16F877A, must make a pulses at the Outputs B0,B1,B2 if the input B3=0.
the Pulses is like this on (300ms) off (300ms) as appear in the program
#include "D:\cc\d\main.h"
int check_change();
void menu();
void end();
void cursor();
int which_MSG();
int8 sen1,sen2,sen3,i;
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);setup_wdt(WDT_18MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
sen1=input(PIN_A0);
sen2=input(PIN_A1);
sen3=input(PIN_A2);
start:
if (check_change()==1) //&& input(PIN_B3)==0 )
goto messaging;
else
goto start;
messaging:
sen1=input(PIN_A0);
sen2=input(PIN_A1);
sen3=input(PIN_A2);
end();
menu();
menu();
menu();
cursor();
cursor();
cursor();
cursor();
menu();
for(i=0; i<which_MSG(); i++)
cursor();
menu();
menu();
cursor();
menu();
menu();
cursor();
menu();
menu();
end();
goto start;
}
int check_change()
{
if( (sen1==input(PIN_A0)) && (sen2==input(PIN_A1)) && (sen3==input(PIN_A2)) )
return 0;
else
return 1;
}
void menu()
{
output_high(PIN_B0);
delay_ms(900);
output_low(PIN_B0);
delay_ms(900);
}
void end()
{
output_high(PIN_B1);
delay_ms(900);
output_low(PIN_B1);
delay_ms(900);
}
void cursor()
{
output_high(PIN_B2);
delay_ms(900);
output_low(PIN_B2);
delay_ms(900);
}
int which_MSG()
{
int8 s1,s2,s3;
s1=input(PIN_A0);
s2=input(PIN_A1);
s3=input(PIN_A2);
if(s1==0 && s2==0 && s3==0)
return 0;
else if(s1==0 && s2==0 && s3==1)
return 1;
else if(s1==0 && s2==1 && s3==0)
return 2;
else if(s1==0 && s2==1 && s3==1)
return 3;
else if(s1==1 && s2==0 && s3==0)
return 4;
else if(s1==1 && s2==0 && s3==1)
return 5;
else if(s1==1 && s2==1 && s3==0)
return 6;
else if(s1==1 && s2==1 && s3==1)
return 7;
}
what is the wrong???