Rev 2578 Rev 2582
Line 1... Line 1...
1 #include "main.h" 1 #include "main.h"
2   2  
3 #define LED1 PIN_E0 3 #define LED1 PIN_E0 // RMC
4 #define LED2 PIN_E1 4 #define LED2 PIN_E1 // 10s
-   5 #define LED3 PIN_E2 // PPS
-   6 #define LED4 PIN_A5 // Fix
-   7  
5 #define SYNC_OUTPUT PIN_E2 8 #define SYNC_OUTPUT PIN_A0
6   9  
7 int1 sync; 10 int1 sync;
8 int8 sec; 11 int8 sec;
9   12  
-   13 // Interrupt from B0
10 #int_EXT 14 #int_EXT
11 void EXT_isr(void) 15 void EXT_isr(void)
12 { 16 {
13 if (sync==1) 17 if (sync==1)
14 { 18 {
15 output_high(SYNC_OUTPUT); 19 output_high(SYNC_OUTPUT);
16 output_toggle(LED2); 20 output_toggle(LED2);
17 delay_us(2); 21 delay_us(5);
18 output_low(SYNC_OUTPUT); 22 output_low(SYNC_OUTPUT);
19 sync=0; 23 sync=0;
20 } 24 }
-   25 output_toggle(LED3);
21 } 26 }
22   27  
23   28  
24   -  
25   -  
26 void main() 29 void main()
27 { 30 {
28   31  
29 setup_adc_ports(NO_ANALOGS|VSS_VDD); 32 setup_adc_ports(NO_ANALOGS|VSS_VDD);
30 setup_adc(ADC_CLOCK_DIV_2); 33 setup_adc(ADC_CLOCK_DIV_2);
31 setup_psp(PSP_DISABLED); -  
32 setup_spi(SPI_SS_DISABLED); 34 setup_spi(SPI_SS_DISABLED);
33 setup_wdt(WDT_OFF); 35 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
34 setup_timer_0(RTCC_INTERNAL); 36 setup_wdt(WDT_2304MS|WDT_DIV_16);
35 setup_timer_1(T1_DISABLED); 37 setup_timer_1(T1_DISABLED);
36 setup_timer_2(T2_DISABLED,0,1); 38 setup_timer_2(T2_DISABLED,0,1);
37 setup_ccp1(CCP_OFF); 39 setup_ccp1(CCP_OFF);
-   40 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
-   41  
-   42  
38 setup_comparator(NC_NC_NC_NC); 43 output_low(SYNC_OUTPUT);
-   44 output_high(LED1);
-   45 output_high(LED2);
39 setup_vref(FALSE); 46 output_high(LED3);
-   47  
-   48 sync=0;
-   49  
40 enable_interrupts(INT_EXT); 50 enable_interrupts(INT_EXT);
41 enable_interrupts(GLOBAL); 51 enable_interrupts(GLOBAL);
42 setup_oscillator(OSC_8MHZ|OSC_TIMER1|OSC_31250|OSC_PLL_OFF); -  
43   52  
44 sync=0; -  
45 //Example blinking LED program -  
46 while(true) 53 while(true)
47 { 54 {
48 while (getch()!='$'); 55 while (getch()!='$');
49 if (getch()!='G') continue; 56 if (getch()!='G') continue;
50 if (getch()!='P') continue; 57 if (getch()!='P') continue;
51 if (getch()!='R') continue; 58 if (getch()!='R') continue;
52 if (getch()!='M') continue; 59 if (getch()!='M') continue;
Line 57... Line 64...
57 getch(); 64 getch();
58 getch(); 65 getch();
59 getch(); 66 getch();
60 output_toggle(LED1); 67 output_toggle(LED1);
61 sec=getch(); 68 sec=getch();
62 if ((sec!='9')) continue; 69 if ((sec=='9')) {sync=1; continue;}
63 sync=1; 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 }
64 } 84 }
65   85  
66 } 86 }