povilas
Junior Member level 1
- Joined
- Mar 4, 2013
- Messages
- 17
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,382
Hello I am using Pic16f873 microcontroller and 6 ds18s20 thermometers. And programing with microC pro. And when I compile program and get replay "There is not enough ROM space".here is my source code:
can anyone help to solve this problem?
Code:
// LCD ekrano prijungimai
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
const unsigned short TEMP_RESOLUTION = 9;// nustatomas konstantos tipas ir sensoriaus tipas
char *text = "000.0"; //nustatomas kintamojo tipas ir pradinė jo reikšmė
unsigned katil, grizta, kamb, akum, saule, karsta, laukas; //kintamasis temperatūros nuskaitymui
//unsigned s_0, s_1, s_2, s_3, s_4,s_5,s_6,s_7;
void Display_Temp(unsigned int temp2write) {
const unsigned short RES_SHIFT = TEMP_RESOLUTION - 8; //priklauso nuo sensoriaus rezoliucijos
char temp_whole;
unsigned int temp_fraction;
int neigtemp = 1;
// Tikrinti ar temperatūra nėra neigiama
if (temp2write & 0x8000) {
text[0] = '-';
temp2write = ~temp2write + 1;
neigtemp=1;
}
else {
neigtemp=0;
}
// gauti kintamąji temp_whole
temp_whole = temp2write >> RES_SHIFT ;
if (!neigtemp) { // tikrinti kintamajį neigtemp
if (temp_whole/100) // Perversti temp_whole į vienetus
text[0] = temp_whole/100 + 48;
else
text[0] = ' ';
}
text[1] = (temp_whole/10)%10+48; // Gauti dešimčių skaičių
text[2] = temp_whole%10 + 48; // Gauti vienetų skaičių
// Gauti kintamojo temp_fraction vienetus po kablelio
temp_fraction = temp2write << (4-RES_SHIFT); // rodo dešimtasias dalis
temp_fraction &= 0x000F;
temp_fraction *= 625;
// Paversti kintamojo temp_fraction duomenis į vienetus
text[4] = temp_fraction/1000 + 48; // Gauti vienetų skaičių po kablelio
// Išvesti temperatūra į LCD ekraną.
Lcd_Out(1, 1, "Temp:");
Lcd_Out(2, 1, "Temp:"); // Išjungti kursorių
// Išvedamas laipsnio ženklas ir celsijaus simbolis
Lcd_Chr(1,11,223);
Lcd_Chr(1,12,'C');
Lcd_Chr(2,11,223);
Lcd_Chr(2,12,'C');
//Lcd_Out(3, 6,text);
}
void main() {
//PORTB = 0; // Reset port D
TRISB = 0b01111111;
ADCON1 = 7 ;
Lcd_Init(); // Inicializuoti LCD
Lcd_Cmd(_LCD_CLEAR); // Išvalyti LCD
Lcd_Cmd(_LCD_CURSOR_OFF);
//Duomenų nuskaitymo programa
do {
//katilo daviklis
//Temperatūros nuskaitymas
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x30);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0xC3);
Ow_Write(&PORTB, 6, 0x44); // Issue command CONVERT_T
Delay_us(600);
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x30);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0xC3);
Ow_Write(&PORTB, 6, 0xBE);
katil = Ow_Read(&PORTB, 6);
katil = (Ow_Read(&PORTB, 6) << 8) + katil;
//--- Format and display result on Lcd
Display_Temp(katil);
Lcd_Out(1, 6,text);
//Delay_ms(120);
//grižtamasis daviklis
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x31);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0xF4);
Ow_Write(&PORTB, 6, 0x44); // Issue command CONVERT_T
Delay_us(600);
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x31);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0xF4);
Ow_Write(&PORTB, 6, 0xBE);
grizta = Ow_Read(&PORTB, 6);
grizta = (Ow_Read(&PORTB, 6) << 8) + grizta;
//--- Format and display result on Lcd
Display_Temp(grizta);
Lcd_Out(2, 6,text);
//Delay_ms(120);
//karšto vandens
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x32);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0xAD);
Ow_Write(&PORTB, 6, 0x44); // Issue command CONVERT_T
Delay_us(600);
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x32);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0xAD);
Ow_Write(&PORTB, 6, 0xBE);
karsta = Ow_Read(&PORTB, 6);
karsta = (Ow_Read(&PORTB, 6) << 8) + karsta;
//--- Format and display result on Lcd
Display_Temp(karsta);
//Lcd_Out(3, 6,text);
//kambario daviklis
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x33);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x9A);
Ow_Write(&PORTB, 6, 0x44); // Issue command CONVERT_T
Delay_us(600);
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x33);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x9A);
Ow_Write(&PORTB, 6, 0xBE);
kamb = Ow_Read(&PORTB, 6);
kamb = (Ow_Read(&PORTB, 6) << 8) + kamb;
//--- Format and display result on Lcd
Display_Temp(kamb);
//Lcd_Out(4, 6,text);
//akumuliacinis daviklis
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x34);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x1F);
Ow_Write(&PORTB, 6, 0x44); // Issue command CONVERT_T
Delay_us(600);
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x34);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x1F);
Ow_Write(&PORTB, 6, 0xBE);
akum = Ow_Read(&PORTB, 6);
akum = (Ow_Read(&PORTB, 6) << 8) + akum;
Display_Temp(laukas);
// Lcd_Out(1, 6,text);
//--- Format and display result on Lcd
//saules kolektoriaus daviklis
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x35);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x28);
Ow_Write(&PORTB, 6, 0x44); // Issue command CONVERT_T
Delay_us(600);
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x35);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x28);
Ow_Write(&PORTB, 6, 0xBE);
saule = Ow_Read(&PORTB, 6);
saule = (Ow_Read(&PORTB, 6) << 8) + saule;
Display_Temp(laukas);
// Lcd_Out(1, 6,text);
//lauko daviklis
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x36);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x28);
Ow_Write(&PORTB, 6, 0x44); // Issue command CONVERT_T
Delay_us(600);
Ow_Reset(&PORTB, 6);
Ow_Write(&PORTB, 6,0x55);
Ow_Write(&PORTB, 6,0x10);
Ow_Write(&PORTB, 6,0x36);
Ow_Write(&PORTB, 6,0xC5);
Ow_Write(&PORTB, 6,0xC8);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x00);
Ow_Write(&PORTB, 6,0x28);
Ow_Write(&PORTB, 6, 0xBE);
laukas = Ow_Read(&PORTB, 6);
laukas = (Ow_Read(&PORTB, 6) << 8) + laukas;
Display_Temp(laukas);
// Lcd_Out(1, 6,text);
} while (1);
}
can anyone help to solve this problem?
Last edited by a moderator: