Rev Author Line No. Line
2578 kakl 1 #include "main.h"
2  
2582 kakl 3 #define LED1 PIN_E0 // RMC
4 #define LED2 PIN_E1 // 10s
5 #define LED3 PIN_E2 // PPS
6 #define LED4 PIN_A5 // Fix
2578 kakl 7  
2582 kakl 8 #define SYNC_OUTPUT PIN_A0
9  
2578 kakl 10 int1 sync;
11 int8 sec;
12  
2582 kakl 13 // Interrupt from B0
2578 kakl 14 #int_EXT
15 void EXT_isr(void)
16 {
17 if (sync==1)
18 {
19 output_high(SYNC_OUTPUT);
20 output_toggle(LED2);
2582 kakl 21 delay_us(5);
2578 kakl 22 output_low(SYNC_OUTPUT);
23 sync=0;
24 }
2582 kakl 25 output_toggle(LED3);
2578 kakl 26 }
27  
28  
29 void main()
30 {
31  
32 setup_adc_ports(NO_ANALOGS|VSS_VDD);
33 setup_adc(ADC_CLOCK_DIV_2);
34 setup_spi(SPI_SS_DISABLED);
2582 kakl 35 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
36 setup_wdt(WDT_2304MS|WDT_DIV_16);
2578 kakl 37 setup_timer_1(T1_DISABLED);
38 setup_timer_2(T2_DISABLED,0,1);
39 setup_ccp1(CCP_OFF);
2582 kakl 40 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
41  
42  
43 output_low(SYNC_OUTPUT);
44 output_high(LED1);
45 output_high(LED2);
46 output_high(LED3);
47  
48 sync=0;
49  
2578 kakl 50 enable_interrupts(INT_EXT);
51 enable_interrupts(GLOBAL);
52  
2582 kakl 53 while(true)
54 {
2578 kakl 55 while (getch()!='$');
56 if (getch()!='G') continue;
57 if (getch()!='P') continue;
58 if (getch()!='R') continue;
59 if (getch()!='M') continue;
60 if (getch()!='C') continue;
61 if (getch()!=',') continue;
62 getch();
63 getch();
64 getch();
65 getch();
66 getch();
67 output_toggle(LED1);
68 sec=getch();
2582 kakl 69 if ((sec=='9')) {sync=1; continue;}
70 getch();
71 getch();
72 getch();
73 getch();
74 getch();
75 if ('A'!=getch())
76 {
77 output_high(LED4); // Neni FIX
78 if (sec=='0') {sync=1;} // Extra click hlasi chybu
79 }
80 else
81 {
82 output_low(LED4);
83 }
84 }
2578 kakl 85  
86 }