//Pluse generator
//input RA0,RA1,RA2 for 10Hz,100Hz,1KHz
//Output RB4
#include <16F628.h>
//#include <16F648A.h>
#use delay(clock=4000000)
#fuses XT,PUT,BROWNOUT,MCLR,NOWDT,NOPROTECT,NOLVP
#define OUTPUT1 PIN_B4
void InitialChip(void)
{
output_a(0);
output_b(0);
set_tris_a(0B11111111);
set_tris_b(0B01101111);
}
void main()
{
delay_ms(200);
InitialChip();
while(1)
{
//SW1 10Hz
if(input(PIN_A0)==0) //Key press
{
delay_ms(100); //Delay and read again
if(input(PIN_A0)==0) //if Key still press
{
while(input(PIN_A0)==0); //wait for release
while(1) //Send Pluse loop
{
output_bit(OUTPUT1,1);
delay_ms(50);
output_bit(OUTPUT1,0);
delay_ms(50);
}
}
}
//SW1 100 Hz
if(input(PIN_A1)==0) //Key press
{
delay_ms(100); //Delay and read again
if(input(PIN_A1)==0) //if Key still press
{
while(input(PIN_A1)==0); //wait for release
while(1) //Send Pluse loop
{
output_bit(OUTPUT1,1);
delay_ms(5);
output_bit(OUTPUT1,0);
delay_ms(5);
}
}
}
//SW1 1KHz
if(input(PIN_A2)==0) //Key press
{
delay_ms(100); //Delay and read again
if(input(PIN_A2)==0) //if Key still press
{
while(input(PIN_A2)==0); //wait for release
while(1) //Send Pluse loop
{
output_bit(OUTPUT1,1);
delay_us(500);
output_bit(OUTPUT1,0);
delay_us(500);
}
}
}
}
}