Rev 2843 Rev 2848
Line 1... Line 1...
1 /**** Automatic weather station 01A ****/ 1 /**** Automatic weather station 01A ****/
2 #define VERSION "0.1" 2 #define VERSION "0.1"
3 #define ID "$Id: main.c 2843 2013-03-18 23:37:51Z kaklik $" 3 #define ID "$Id: main.c 2848 2013-03-21 08:16:49Z kakl $"
4 #include "main.h" 4 #include "main.h"
5 #include ".\common\dbloader.h" 5 #include ".\common\dbloader.h"
6 #include <string.h> 6 #include <string.h>
7   7  
8 #CASE // Case sensitive compiler 8 #CASE // Case sensitive compiler
Line 27... Line 27...
27   27  
28 #int_TIMER1 28 #int_TIMER1
29 void TIMER1_isr(void) 29 void TIMER1_isr(void)
30 { 30 {
31 output_toggle(PIN_E0); 31 output_toggle(PIN_E0);
-   32 set_timer1(0);
-   33
32 // anemo = ((timer0_overflow_count * 0xFF) + get_timer0())/(32768.0/0xFFFF); 34 // anemo = ((timer0_overflow_count * 0xFF) + get_timer0())/(32768.0/0xFFFF);
33 // timer0_overflow_count=0; 35 // timer0_overflow_count=0;
34 // set_timer0(0); 36 // set_timer0(0);
35 } 37 }
36   38  
Line 52... Line 54...
52 { 54 {
53 char REV[50]=ID; // Buffer for concatenate of a version string 55 char REV[50]=ID; // Buffer for concatenate of a version string
54   56  
55 if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; 57 if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0;
56 printf("\r\n\r\n# AWS01A %s (C) 2013 www.mlab.cz \r\n",VER); // Welcome message 58 printf("\r\n\r\n# AWS01A %s (C) 2013 www.mlab.cz \r\n",VER); // Welcome message
57 restart_wdt(); //---WDT -  
58 printf("#%s\r\n",&REV[4]); 59 printf("#%s\r\n",&REV[4]);
59 printf("# ver seq temp[mK] hum_temp[mK] hum[%%] "); 60 printf("# ver seq temp[mK] hum_temp[mK] hum[%%] ");
60 restart_wdt(); //---WDT -  
61 printf("bar_temp[mK] pressure[hPa] Anemo[pls/s]check\r\n\r\n"); 61 printf("bar_temp[mK] pressure[hPa] Anemo[pls/s]check\r\n\r\n");
62   -  
63 restart_wdt(); //---WDT -  
64 } 62 }
65   63  
66 void main() 64 void main()
67 { 65 {
68 unsigned int16 seq=0; 66 unsigned int16 seq=0;
69   67  
-   68 setup_oscillator(OSC_8MHZ); // pri prouziti bootloaderu neni treba nastavovat
-   69 setup_wdt(WDT_2304MS);
70 restart_wdt(); //---WDT 70 restart_wdt(); //---WDT
71 setup_adc_ports(NO_ANALOGS|VSS_VDD); 71 setup_adc_ports(NO_ANALOGS|VSS_VDD);
72 setup_adc(ADC_CLOCK_DIV_2); 72 setup_adc(ADC_CLOCK_DIV_2);
73 //!!! setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1); 73 setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
74 // setup_timer_1(T1_INTERNAL|T1_DIV_BY_1|T1_CLK_OUT); 74 // setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);//|T1_CLK_OUT);
75 setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); 75 setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
76 setup_timer_2(T2_DISABLED,0,1); 76 setup_timer_2(T2_DISABLED,0,1);
77 setup_ccp1(CCP_OFF); 77 setup_ccp1(CCP_OFF);
78 setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard 78 setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
79 // setup_oscillator(OSC_8MHZ); // pri prouziti bootloaderu neni treba nastavovat -  
80 // setup_wdt(WDT_2304MS); -  
81 setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64); 79 setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64);
82 output_high(CSN_SPI); 80 output_high(CSN_SPI);
83   81  
84 // delay_ms(100); -  
85   -  
86 welcome(); // welcome print and device indentification 82 welcome(); // welcome print and device indentification
87 output_low(PIN_E1); 83 output_low(PIN_E1);
88 // delay_ms(100); -  
89 restart_wdt(); //---WDT -  
90   -  
91 // sht_init(); -  
92 // MPL_init(); // get correction coefficients from the sensor -  
93   84
94 enable_interrupts(INT_TIMER1); // interrupts used for anemometer readings 85 enable_interrupts(INT_TIMER1); // interrupts used for anemometer readings
95 //enable_interrupts(INT_TIMER0); 86 //enable_interrupts(INT_TIMER0);
96 // disable_interrupts(INT_RDA); 87 // disable_interrupts(INT_RDA);
97 enable_interrupts(GLOBAL); 88 enable_interrupts(GLOBAL);
98 -  
99 output_high(PIN_E1); 89 output_high(PIN_E1);
100 // delay_ms(200); -  
101 restart_wdt(); //---WDT -  
102 while (TRUE) -  
103 { 90  
104 // output_toggle(PIN_E0); -  
105 delay_ms(200); -  
106 restart_wdt(); //---WDT 91 restart_wdt(); //---WDT
107   92  
-   93 sht_init();
-   94 MPL_init(); // get correction coefficients from the sensor
108 } 95
-   96 restart_wdt(); //---WDT
109   97  
110 while (TRUE) 98 while (TRUE)
111 { 99 {
112 char output[8]; // Output buffer 100 char output[8]; // Output buffer
113 int8 j; // String pointer 101 int8 j; // String pointer