/Designs/Measuring_instruments/AWS01A/SW/PIC16F887/main.c
29,6 → 29,8
void TIMER1_isr(void)
{
output_toggle(PIN_E0);
set_timer1(0);
// anemo = ((timer0_overflow_count * 0xFF) + get_timer0())/(32768.0/0xFFFF);
// timer0_overflow_count=0;
// set_timer0(0);
54,13 → 56,9
 
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0;
printf("\r\n\r\n# AWS01A %s (C) 2013 www.mlab.cz \r\n",VER); // Welcome message
restart_wdt(); //---WDT
printf("#%s\r\n",&REV[4]);
printf("# ver seq temp[mK] hum_temp[mK] hum[%%] ");
restart_wdt(); //---WDT
printf("bar_temp[mK] pressure[hPa] Anemo[pls/s]check\r\n\r\n");
 
restart_wdt(); //---WDT
}
 
void main()
67,46 → 65,36
{
unsigned int16 seq=0;
 
setup_oscillator(OSC_8MHZ); // pri prouziti bootloaderu neni treba nastavovat
setup_wdt(WDT_2304MS);
restart_wdt(); //---WDT
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
//!!! setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
// setup_timer_1(T1_INTERNAL|T1_DIV_BY_1|T1_CLK_OUT);
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
// setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);//|T1_CLK_OUT);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
// setup_oscillator(OSC_8MHZ); // pri prouziti bootloaderu neni treba nastavovat
// setup_wdt(WDT_2304MS);
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64);
output_high(CSN_SPI);
 
// delay_ms(100);
 
welcome(); // welcome print and device indentification
output_low(PIN_E1);
// delay_ms(100);
restart_wdt(); //---WDT
 
// sht_init();
// MPL_init(); // get correction coefficients from the sensor
 
output_low(PIN_E1);
enable_interrupts(INT_TIMER1); // interrupts used for anemometer readings
//enable_interrupts(INT_TIMER0);
// disable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
output_high(PIN_E1);
 
restart_wdt(); //---WDT
 
sht_init();
MPL_init(); // get correction coefficients from the sensor
output_high(PIN_E1);
// delay_ms(200);
restart_wdt(); //---WDT
while (TRUE)
{
// output_toggle(PIN_E0);
delay_ms(200);
restart_wdt(); //---WDT
 
}
 
while (TRUE)
{
char output[8]; // Output buffer