#include "main.h"
#define LED PIN_D7
#define RECORDS 100
void main()
{
int16 time, time_new;
int16 log[RECORDS];
int16 n;
setup_adc_ports(AN0_TO_AN7|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_EXT_H_TO_L);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
output_low(LED);
/*
while(true)
{
output_low(LED);
delay_ms(1);
output_high(LED);
delay_ms(1);
printf("%u\n\r", 0x55);
}
//*/
n=0;
while(true)
{
set_timer0(0);
time = 0;
time_new = 0;
while(time_new == 0)
{
time_new=get_timer0();
}
output_high(LED);
while(time != time_new)
{
time=time_new;
time_new=get_timer0();
delay_us(5);
}
if (time>3){ log[n++]=time;}
if (n==RECORDS)
{
for (n=0; n<RECORDS; n++) printf("%Lu,", log[n]);
printf("\n\r");
n = 0;
}
output_low(LED);
}
}