0,0 → 1,74 |
#include "D:\svnKaklik\programy\C\PIC\mereni\TDC\Pulzni_generator\main.h" |
|
#use fast_io (D) |
|
#define LED PIN_E1 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5 |
|
#define START PIN_D4 |
#define STOP1 PIN_D5 |
#define STOP2 PIN_D7 |
|
|
void main() |
{ |
|
setup_adc_ports(NO_ANALOGS|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_INTERNAL); |
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); |
|
//Example blinking LED program |
while(true){ |
output_low(LED); |
delay_ms(1000); |
output_high(LED); |
delay_ms(1000); |
} |
|
// Mode 1 |
|
TDC_init(); |
|
delay_ms(50); |
output_low(START); |
output_low(STOP1); |
output_low(STOP2); |
|
output_high(START); // start of time measurement |
|
output_high(STOP2); |
output_high(STOP1); |
|
output_low(STOP1); |
output_low(STOP2); |
output_low(START); |
|
|
// mode 2 |
|
output_high(STOP2); // Merime jenom jednim kanalem (druhy musi byt v H) |
|
output_high(START); |
output_low(START); |
delay_us(150); |
|
output_high(STOP1); |
output_low(STOP1); |
delay_us(1); |
|
output_high(STOP1); |
output_low(STOP1); |
delay_us(10); |
|
output_high(STOP1); |
output_low(STOP1); |
delay_us(1); |
} |