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'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";
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; }
void writeText( char *txt ) { while( *txt ) { writeChar(*txt++); delay(250); } }
That's not the case! For the actual output of the character to the LCD I use a separate function. When called to put out a single char, this works fine, or called in a loop to put out characters it also works. It only print out garbage when called out of the sting routine! I really suspect a memory access or pointer problem. cheers Rolf
I don't understand. Your writeText() function IS a loop which calls your character output function. What exactly does work, what does it / does it not work on and can you post a bit more of your code? Stefan
to answer the question in the subject line: because if simulates Erik
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.
When you start the simulator, it clears all the RAM to zero; when you powerup your real hardware, the RAM contains random junk. If you have uninitialised variables in your code, this can lead to it working in the simulator but not the target.
ok! you where right. It was a timing problem and the port was at a certain time in an inconsistent state. Thanks for you help!