#include "C:\Users\Honza\Documents\pic\serio_tlak\pic\main.h"
/**** Automatic weather station 01A ****/
#define VERSION "0.1"
#define ID "$Id: main.c 2858 2013-03-22 16:04:13Z kaklik $"
#include <string.h>
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8) //rcv TXD xmit RXD
#CASE // Case sensitive compiler
#define SEND_DELAY 50 // Time between two characters on RS232
#define CSN_SPI PIN_C2 // preassure sensor connection
#include "..\MPL115A1.c"
void welcome(void) // Welcome message
{
char REV[50]=ID; // Buffer for concatenate of a version string
if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0;
printf("# ver seq temp[mK] hum_temp[mK] hum[%%] ");
printf("bar_temp[mK] pressure[hPa] Anemo[pls/s]check\r\n\r\n");
}
void main()
{
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_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_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_64);
output_high(CSN_SPI);
welcome(); // welcome print and device indentification
restart_wdt(); //---WDT
MPL_init(); // get correction coefficients from the sensor
restart_wdt(); //---WDT
while (TRUE)
{
char output[8]; // Output buffer
int8 j; // String pointer
int8 check=0; // Checksum is calculated between '$' and '*'
float barometer_temperature, barometer_pressure;
delay_ms(1000);
//barometer_temperature = (MPL_get_temperature() + 273.15)*100;
//barometer_pressure = MPL_get_pressure() * 10.0; // conversion to hectopascals
printf("%5.1f \0",barometer_pressure);
}
}