Hello all,
Can anyone help me with a problem? I am trying to write some code, I am using the lite version of PICC.
It is extremely irritating when it says I can compile this 400 words better if you pay $1000, I am a hobbyist, so can't afford that. I am considering porting to SDCC to get around this 'warning'
My problem, I am running out of space, I think that I could fit the whole rest of the program in maybe 50-100 words.
This routine, is taking 450 words.
Idea is I have stored the addresses in local eeprom, I am passing the routine a char with a number of the sensor, and an array of chars, 3 digits long, each digit will store a digit of the number to be displayed.
The conversion routine is based upon some code from Christian Stadler (found online, can't find the website now)
The code effectively multiplies up the number by 256 during the conversion, to allow for full accuracy. I want to get one decimal place put into digits[2]
The 'main' waste of space is the division, which is taking >100 words.
I have left digits[0] and [1] intact below, and commented out 'attempts' around digits[2].
MatchRom, Write and Reset appear to be reasonably optimised, my main 'waste' of code is in the arithmetic.
So can anyone suggest a better way of doing the maths, or whether using SDCC might save me the space I need? (The PICC I think it not trying to optimise).
Can anyone help me with a problem? I am trying to write some code, I am using the lite version of PICC.
It is extremely irritating when it says I can compile this 400 words better if you pay $1000, I am a hobbyist, so can't afford that. I am considering porting to SDCC to get around this 'warning'
My problem, I am running out of space, I think that I could fit the whole rest of the program in maybe 50-100 words.
This routine, is taking 450 words.
Idea is I have stored the addresses in local eeprom, I am passing the routine a char with a number of the sensor, and an array of chars, 3 digits long, each digit will store a digit of the number to be displayed.
The conversion routine is based upon some code from Christian Stadler (found online, can't find the website now)
The code effectively multiplies up the number by 256 during the conversion, to allow for full accuracy. I want to get one decimal place put into digits[2]
The 'main' waste of space is the division, which is taking >100 words.
I have left digits[0] and [1] intact below, and commented out 'attempts' around digits[2].
MatchRom, Write and Reset appear to be reasonably optimised, my main 'waste' of code is in the arithmetic.
So can anyone suggest a better way of doing the maths, or whether using SDCC might save me the space I need? (The PICC I think it not trying to optimise).
Rich (BB code):
void gettemp(unsigned char sensornum,unsigned char (*digits)){
D_Reset();
D_MatchRom(0x0e+8*sensornum);
D_Write(0xbe);
unsigned char temp[8];
unsigned char r=0;
while(r<8){
temp[r]=D_Read();
r++;
}
unsigned int hres=0;
unsigned int tres=0;
tres =temp[1]<<8;
tres |=temp[0];
if(0x02 !=sensornum){
hres=tres<<4;
}else{
tres >>= 1;
tres <<= 8;
tres -= 0x100>>2;
hres =0x10-temp[6];
hres <<=4;
hres +=tres;
}
//div_t ty=div(hres,2);
digits[0]=(hres>>8)/10;
digits[1]=(hres>>8)-digits[0]*10;
//hres-=(digits[0]*10)<<8;
//hres-=(digits[1])<<8;
//hres *=10;
digits[2]=hres%256;
//((hres)>>6)&0b00000111;
//int t=10*hres>>8;
}