#include<pic.h>
#include<htc.h>
//__CONFIG(HS & PWRTEN & BOREN & LVPEN & WDTDIS & DUNPROT & DEBUGDIS);
__CONFIG1(FOSC_HS & PWRTE_ON & BOREN_OFF & WDT_OFF & MCLRE_ON & CP_OFF & CLOCKOUT_ON & IESO_OFF & FCMEN_OFF);
__CONFIG2(WRT_OFF & VCAPEN_OFF & LVP_OFF & LPBOR_OFF & BORV_OFF & STVR_ON);
//unsigned int value1,value2;
void main()
{
ADCON1=0X06; ;
TRISA = 0xFF; /* Configure RA<0...7> as input */
TRISB = 0xFF; /* Configure RB<0...7> as input */
TRISD = 0x00; /* Configure RD<0...7> as output */
TRISC = 0x80; /* Configure RC0, RC1, RC3, RC4, RC5 and Tx(RC6) as output */
TRISE = 0x00;
TRISF = 0x00;
TRISG = 0x00;
CCP1CON=0X0C;
T2CON=0X04;
//CCPR2L=0x3F;
PR2=24;
CCPTMRS0=0x00;
CCPTMRS1=0x00;
CCPTMRS2=0x00;
PORTA=0x00;
PORTC=0x00;
PORTB=0x00;
PORTD=0x00;
PORTE=0x00;
PORTF=0x00;
PORTG=0x00;
while(1)
{
ADCON0=0X80;
//delay();
ADGO=1;
//while(ADGO);
//value1=ADRESH*255+ADRESL;
//value1=value1/4;
//T2CON=0X04;
CCP1CON=0b00011100;
CCPR1L=0b00000001;// 5%duty cycle 100khz
}
}
delay()
{
unsigned int i;
for(i=0;i<200;i++);
}