We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have 8031 connected with 64KB external EPROM and 8KB external RAM.
I around 15 C files and after compiling all the files my xdata size is - 4450 and code - 37750.
But i face a problem in executing a particular block of a program.
the block has one for loop, and after completing the for loop has a sprintf function.
both the routines are correct but i dont understand if i remove the forloop only my sprintf is executing.
if i put my for loop the spritnf is not working. the function i do inside the forloop is very correct.
since this type of routine that is the for loop + sprintf is used in 4 places. The first 3 places there is no problem but the problem comes in last place.
i do not know y the compiler is behaving in a peculiar manner?
can anybody help me regarding this?
Here is my code,
void Monitor_Slot4(void) { if(Slot_4 == 0) { Dev_Curr = fNewVREF_4 / Res; DevCurr_MinLimit = Dev_Curr - PassBand; DevCurr_MaxLimit = Dev_Curr + PassBand; //ROUTINE TO CHECK THE DEVICE VOLTAGE for(r=73;r<=92;r++) { fMonDevVol = 0.0; fMonDevVol = fReadVoltage(r); Arr[r][s] = fMonDevVol; if(s >= 9) { s = 0; flt_Average(Arr); } } //ROUTINE TO CHECK THE VREF fMonVREF_4 = 0.0; fMonVREF_4 = fReadVoltage(93); fMonVREF = fMonVREF_4; sprintf(temp3,"VREF4= % ",fMonVREF); LCD_Display(temp3,0x94); VREF_Check(); fMonVREF = 0.0; //ROUTINE TO CHECK THE VPOS fMonVPOS = 0.0; fMonVPOS = fReadVoltage(94); fMonVPOS = fMonVPOS * 4.99; VPOS_Check(); fMonVPOS = 0.0; //ROUTINE TO CHECK THE VNEG fMonVNEG = 0.0; fMonVNEG = fReadVoltage(95); fMonVNEG = fMonVNEG * 4.99; VNEG_Check(); fMonVNEG = 0.0; } return; }
This is the code used for monitoring slot 4 in my project.
Like this i have slot 1,2 and 3. I hvae written the same code. The only difference is the channel number used in my for loop and the value passed in the other fuinctions are changing thats it.
No other change is done.
But the routine for the slot1,2,3 are running quite well. But the same routine for slot 4 is not running.
If i remove the for loop only the program is running otherwise the system stops before the sprintf statement.
If i put the for loop then the sprintf is not working.
I have tested with printf statements all the parmters are found to be correct but i dont know y the troublke is coming.
Please give me a suggestion how to rectify this problem.
I have declared r and s of the for loop as integer (global).
"Arr[r][s] = fMonDevVol;"
Is 's' initialized before its use?
ya i found the error.
Actually i declared Arr[81][10] globally and in the function passed arr[87].
Thank you very much.