program cannot work without "printf"

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Wilbur He on Tue Apr 14 07:36:43 MST 2015
Hi all, I have met a problem which is I must put a printf inside the function, otherwise it won't work. I have tried many ways such as replace printf with a delay or some other commands. the function still didn't work. It only worked if i put a printf inside. (no matter what i printed). Here is the codes of my function:

while(test==1)// while main heart switch is activated
if(time(NULL) >= duration) //when 15 seconds is up
finalcount = 4* count; //calculate total number of counts
heartcheck(finalcount); //check if motor should be activated
sprintf(buffer,"%d",finalcount);//result to string for display
lcdClrScr();//clear to show new result
lcdPutString("Heartbeats/Min"); //upper
lcdPutString(buffer); //lower

count=0;//reset count for another loop
duration= (time(NULL)+15);// reset 15 seconds later

else // if still not 15 seconds
Read_Pulse();// read pulse