Subversion Repositories svnkaklik

Rev

Rev 854 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
853 kaklik 1
#include "D:\svnKaklik\programy\C\PIC\mereni\TDC\Pulzni_generator\main.h"
2
 
3
#use fast_io (D)
4
 
5
#define LED PIN_E1  //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
6
 
7
#define START  PIN_D4
8
#define STOP1  PIN_D5
9
#define STOP2  PIN_D7
10
 
11
 
12
void main()
13
{
14
 
15
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
16
   setup_adc(ADC_CLOCK_DIV_2);
17
   setup_psp(PSP_DISABLED);
18
   setup_spi(SPI_SS_DISABLED);
19
   setup_wdt(WDT_OFF);
20
   setup_timer_0(RTCC_INTERNAL);
21
   setup_timer_1(T1_DISABLED);
22
   setup_timer_2(T2_DISABLED,0,1);
23
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
24
   setup_ccp1(CCP_OFF);
25
   setup_comparator(NC_NC_NC_NC);
26
   setup_vref(FALSE);
27
 
28
    //Example blinking LED program
29
    while(true){
30
      output_low(LED);
31
      delay_ms(1000);
32
      output_high(LED);
33
      delay_ms(1000);
34
    }
35
 
36
// Mode 1
37
 
38
      TDC_init();
39
 
40
      delay_ms(50);
41
      output_low(START);
42
      output_low(STOP1);
43
      output_low(STOP2);
44
 
45
      output_high(START);     // start of time measurement
46
 
47
      output_high(STOP2);
48
      output_high(STOP1);
49
 
50
      output_low(STOP1);
51
      output_low(STOP2);
52
      output_low(START);
53
 
54
 
55
// mode 2
56
 
57
      output_high(STOP2);  // Merime jenom jednim kanalem (druhy musi byt v H)
58
 
59
      output_high(START);
60
      output_low(START);
61
      delay_us(150);
62
 
63
      output_high(STOP1);
64
      output_low(STOP1);
65
      delay_us(1);
66
 
67
      output_high(STOP1);
68
      output_low(STOP1);
69
      delay_us(10);
70
 
71
      output_high(STOP1);
72
      output_low(STOP1);
73
      delay_us(1);
74
}