Rev Author Line No. Line
2578 kakl 1 #include "main.h"
2  
3 #define LED1 PIN_E0
4 #define LED2 PIN_E1
5 #define SYNC_OUTPUT PIN_E2
6  
7 int1 sync;
8 int8 sec;
9  
10 #int_EXT
11 void EXT_isr(void)
12 {
13 if (sync==1)
14 {
15 output_high(SYNC_OUTPUT);
16 output_toggle(LED2);
17 delay_us(2);
18 output_low(SYNC_OUTPUT);
19 sync=0;
20 }
21 }
22  
23  
24  
25  
26 void main()
27 {
28  
29 setup_adc_ports(NO_ANALOGS|VSS_VDD);
30 setup_adc(ADC_CLOCK_DIV_2);
31 setup_psp(PSP_DISABLED);
32 setup_spi(SPI_SS_DISABLED);
33 setup_wdt(WDT_OFF);
34 setup_timer_0(RTCC_INTERNAL);
35 setup_timer_1(T1_DISABLED);
36 setup_timer_2(T2_DISABLED,0,1);
37 setup_ccp1(CCP_OFF);
38 setup_comparator(NC_NC_NC_NC);
39 setup_vref(FALSE);
40 enable_interrupts(INT_EXT);
41 enable_interrupts(GLOBAL);
42 setup_oscillator(OSC_8MHZ|OSC_TIMER1|OSC_31250|OSC_PLL_OFF);
43  
44 sync=0;
45 //Example blinking LED program
46 while(true)
47 {
48 while (getch()!='$');
49 if (getch()!='G') continue;
50 if (getch()!='P') continue;
51 if (getch()!='R') continue;
52 if (getch()!='M') continue;
53 if (getch()!='C') continue;
54 if (getch()!=',') continue;
55 getch();
56 getch();
57 getch();
58 getch();
59 getch();
60 output_toggle(LED1);
61 sec=getch();
62 if ((sec!='9')) continue;
63 sync=1;
64 }
65  
66 }