Rich (BB code):
//bimary 0b110
//hexadecimal 0xA
//dec imal 110
#define XTAL_FREQ 4MHZ
#include <htc.h>
#include <pic.h>
#include "delay.h"
#include <stdio.h>
#include "lcd.h"
#include <math.h>
__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & BOREN_OFF & LVP_OFF);
//global variable
unsigned char temperature;
char ADC_VALUE[32];
char helo[32];
char helow[32];
unsigned char temp2 = 0;
unsigned char finalpressure2;
void pic_init();
unsigned int getAdd();
void main(void) {
unsigned int adcValue;
unsigned int adcValue2;
unsigned char base;
float voltage;
float altitude;
float voltage2;
float pressure;
float finalpressure;
pic_init();
lcd_init();
DelayMs(10);
while (1) {
ADCON0 = 0b00001001;
// DelayUs(1000);
// GO_DONE = 1;
// while (GO_DONE) {
// continue;
// }
adcValue = getAdd();//((ADRESH << 8) | ADRESL);
voltage = adcValue * 5.0 / 1023;
voltage = voltage * 100 + 3.0;
temperature = (unsigned char) voltage;
temp2 = (voltage - temperature)*10;
sprintf(ADC_VALUE, "%d.%d deg Celciuselo h", temperature, temp2);
lcd_clear();
lcd_goto(1, 1);
lcd_puts(ADC_VALUE);
DelayMs(1500);
ADCON0 = 0b00010001;
// DelayUs(1000);
// GO_DONE = 1;
//
// while (GO_DONE) {
// continue;
// }
adcValue2 = getAdd();//((ADRESH << 8) | ADRESL);
voltage2 = adcValue2 * 5.0 / 1023;
pressure = (((voltage2 / 5.0) + 0.095) / 0.009);
altitude = (1-pow((pressure/101.1325),0.190263))*44330.32172;
base = (unsigned char) altitude;
sprintf(ADC_VALUE, "%d ", base);
lcd_clear();
lcd_goto(1, 1);
lcd_puts(ADC_VALUE);
lcd_goto(2, 1);
lcd_puts("altitude meter");
DelayMs(1000);
sprintf(helow, "%.2f hpa", pressure * 10-3);
lcd_clear();
lcd_goto(1, 1);
lcd_puts(helow);
DelayMs(1500);
if (RB2 == 0) {
RB1 = 1;
DelayMs(2000);
RB1 = 0;
TMR0 = 0;
lcd_clear();
lcd_goto(1, 1);
lcd_puts("pulse counting");
lcd_goto(2, 1);
lcd_puts("pls wait for 20 second");
DelayMs(23000);
RB1 = 1;
sprintf(helo, "your pulse is %d ", TMR0 * 3);
lcd_clear();
lcd_goto(1, 1);
lcd_puts(helo);
DelayMs(1000);
}
RB1 = 0;
}
}
void pic_init() {
TRISC = 0xff;
TRISB = 0b00000101;
TRISD = 0x00;
PORTB = 0x00;
PORTD = 0x00;
TRISA = 0xff;
//let portA analogue converted to analogue enable
ADCON1 = 0b11000000;
OPTION_REG = 0b00101000;
}
unsigned int getAdd(){
DelayUs(1000);
GO_DONE = 1;
while (GO_DONE) {
continue;
}
return((ADRESH << 8) | ADRESL);
}
This is my code, everytime when i compile it will have error, i found out that this line
altitude = (1-pow((pressure/101.1325),0.190263))*44330.32172;
is causing the problem but i duno how to fix it
the error message is
:0: error: can't find 0x78 words (0x78 withtotal) for psect "text831" in class "CODE" (largest unused contiguous range 0x49)
:0: error: can't find 0x76 words (0x76 withtotal) for psect "text850" in class "CODE" (largest unused contiguous range 0x49)
:0: error: can't find 0x6F words (0x6f withtotal) for psect "text842" in class "CODE" (largest unused contiguous range 0x49)
:0: error: can't find 0x6E words (0x6e withtotal) for psect "text846" in class "CODE" (largest unused contiguous range 0x49)
:0: error: can't find 0x6C words (0x6c withtotal) for psect "text847" in class "CODE" (largest unused contiguous range 0x49)
:0: error: can't find 0x66 words (0x66 withtotal) for psect "text845" in class "CODE" (largest unused contiguous range 0x49)
:0: error: can't find 0x5E words (0x5e withtotal) for psect "text849" in class "CODE" (largest unused contiguous range 0x49)
:0: error: can't find 0x4E words (0x4e withtotal) for psect "text860"