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

Why is simulator not equal to real life hardware?

I'm new to embeded C. I've got a Phytec Philips C552 chip and connected a LCD to it. I've made a simple prg to display char or string. Char works perfectly string brings only garbage. When I run the prg in sim it looks ok to me, on the target hardware not. I've browsed thru the forum and found some threads about STARTUP.A51a nd pointers. I've no idea if this problems applies to me. Here some code fragments of my prg:

Just after the <includes> is:

code const char welcome[] = "Hello World";

The function to write a single character works fine:
void writeChar( char dataOut )
{
	checkBF();
	P4 = 0;
	P4 = _iror_( (dataOut & 0xF0),4 );
	RS = 1;
	E = 1;
	_nop_();
	E = 0;
	P4 = (dataOut & 0x0F);
	RS = 1;
	E = 1;
	_nop_();
	E = 0;
}

Here the function to print a whole string which brings garbage:
void writeText( char *txt  )
{
	while( *txt )
	{
	writeChar(*txt++);
	delay(250);
	}
}

Any help appreciated!

Rolf

Parents
  • I really suspect a memory access or pointer problem.

    Your example is a little to incomplete to be sure, but this does indeed look like the most probable reason.

    Have you tried the suggestion made by someone else here, to remove the 'code' attribute from your string constant? Or just passed an literal string constant to your function, as a cross check?

    Make extra sure you have a prototype for your function in scope at the point you're using it.

Reply
  • I really suspect a memory access or pointer problem.

    Your example is a little to incomplete to be sure, but this does indeed look like the most probable reason.

    Have you tried the suggestion made by someone else here, to remove the 'code' attribute from your string constant? Or just passed an literal string constant to your function, as a cross check?

    Make extra sure you have a prototype for your function in scope at the point you're using it.

Children