This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

One line of correct code causing entire program

I am using NEX Robotics board for LPC2148. I find very strange problem with below lines of code.

//Prototypes
void diaplayInRow1WithPosition(unsigned char* data, unsigned char position);
void diaplayInRow2WithPosition(unsigned char* data, unsigned char position);
unsigned char convertHigherNibbleToASCIIValue(unsigned char data);
unsigned char convertLowerNibbleToASCIIValue(unsigned char data);
int main (void)
{ unsigned char temp2; unsigned int PLLStatus; initializeAll(); PLLStatus = PLL0STAT; temp2 = convertLowerNibbleToASCIIValue(PLLStatus); diaplayInRow1WithPosition(&temp2,15); temp2 = convertHigherNibbleToASCIIValue(PLLStatus); diaplayInRow1WithPosition(&temp2,14); temp2 = PLLStatus>>8; temp2 = convertLowerNibbleToASCIIValue(PLLStatus); diaplayInRow1WithPosition(&temp2,13); return(0);
} When this code is executed, I see a blank display. I noticed that the problem is with last convertLowerNibbleToASCIIValue function call. It should have been:

temp2 = convertLowerNibbleToASCIIValue(temp2 );
But because of this one line error, why entire display is blank? Only last function diaplayInRow1WithPosition should have given trouble right? Even after changing with above line, I am getting blank display. So I replaced that line containing last convertLowerNibbleToASCIIValue as

temp2 = convertLowerNibbleToASCIIValue(PLLStatus>>8);
And finally I got correct display.

Unable to digest the problem. Anyone can help? Main answer I need is if at all there is a problem in one line, why previous lines are not getting executed correctly? I am using Keil compiler and any compiler dependencies? There is no compilation error. If there is a problem with types etc, will entire program get corrupted? Also I noticed that adding extra dummy line such as temp=10; changes the behavior even though temp variable is not utilized.

Parents Reply Children