Rev 4836 Rev 4837
1 #include "main.h" 1 #include "main.h"
2   2  
3   3  
4 #define T1 PIN_D1 // charging 4 #define T1 PIN_D1 // charging
5 #define T2 PIN_D2 // discharging 5 #define T2 PIN_D2 // discharging
6   6  
7 void main() 7 void main()
8 { 8 {
9   9  
10 setup_adc_ports(NO_ANALOGS|VSS_VDD); 10 setup_adc_ports(NO_ANALOGS|VSS_VDD);
11 setup_adc(ADC_CLOCK_DIV_2); 11 setup_adc(ADC_CLOCK_DIV_2);
12 setup_spi(SPI_SS_DISABLED); 12 setup_spi(SPI_SS_DISABLED);
13 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 13 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
14 setup_timer_1(T1_DISABLED); 14 setup_timer_1(T1_DISABLED);
15 setup_timer_2(T2_DISABLED,0,1); 15 setup_timer_2(T2_DISABLED,0,1);
16 setup_ccp1(CCP_OFF); 16 setup_ccp1(CCP_OFF);
17 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard 17 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
18 setup_oscillator(OSC_8MHZ); 18 setup_oscillator(OSC_8MHZ);
19   19  
20 output_high(T1); 20 output_high(T1);
21 output_high(T2); 21 output_low(T2);
22 delay_ms(1000); 22 delay_ms(1000);
23   23  
24 while(true) 24 while(true)
25 { 25 {
26 output_low(T1); // charge 26 output_low(T1); // charge
27 delay_ms(1000); 27 delay_ms(2000);
28 output_high(T1); // charge off 28 output_high(T1); // charge off
29 delay_ms(300); 29 delay_ms(300);
30 output_low(T2); // discharge 30 output_high(T2); // discharge
31 delay_ms(200); 31 delay_ms(200);
32 output_high(T2); // discharge off 32 output_low(T2); // discharge off
33 delay_ms(300); 33 delay_ms(300);
34 } 34 }
35   35  
36 } 36 }