MAIN FUNCTION
#include ;
#include ;
void delay_time(void); //delay function declare
void init(void); //I/O PORT initialize function declare
const char TABLE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92}; // define constant 0-5 data table
void main()
{
while(1) //dead circle,LED continue light
{
init();
char fpga='0';
char fpga1='0';
fpga= input_c() ;
fpga1= fpga;
switch(fpga1)
{
case 0:
output_d(TABLE[0]);
output_a(0b00111110);
output_b(fpga1);
break;
case 1 :
output_d(TABLE[1]);
output_a(0b00111110);
output_b(fpga1);
break;
case 2:
output_d(TABLE[2]);
output_a(0b00111110);
output_b(fpga1);
break;
case 3:
output_d(TABLE[3]);
output_a(0b00111110);
output_b(fpga1);
break;
default:
output_d(TABLE[3]);
output_a(0b00111110);
output_b(fpga1);
break;
}
}
}
void init()
{
set_tris_a( 0 ); // set GP1 output, all other inputs
set_tris_c( 11101111 ); // set GP1 output, all other inputs
set_tris_b( 0 ); // set GP1 output, all other inputs
set_tris_d( 0 );
setup_comparator( NC_NC_NC_NC ); // disable comparators
setup_adc_ports( NO_ANALOGS ); // disable analog inputs
setup_adc( ADC_OFF ); // disable A2D
//output_low(PIN_C4);
}
void delay_time() //delay function
{
int i; //
for(i=100;i--;); //delay
}
CONFIGURATION FILE
#include <16f877a .h="">;
#device ADC=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(crystal=4000000)
16f877a>
No comments:
Post a Comment