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 a problem with controller output. ( From controller's serial port via COM port i send data to my PC, and can recieve it on PC's Hyperterminal ). While testing the programm into debugger ( Keil C251 uVision2 ), i recieve the string, that i was sent from the programm. But from real controller i recieve that: if i use code
for ( i = 0; i < strlen (MyString); i ++) { TI = 0; SBUF = MyString[i]; while(!TI); }
for ( i = 0; i < 6; i ++) { TI = 0; SBUF = MyString[i]; while(!TI); }
What is the definition of MyString and your loop variable i ? What is output if you run the program in the simulator ? Looks like a missing zero to terminate the string. HHK
Yes - check for that NULL terminator!
Thanks for answer MyString & i are "unsigned char". Gennady
Thanks to everybody a lot. It works perfect. My problem realy was a NULL terminator. Thanks Gennady.
The variable MyString is probably NOT the same name as the string variable that you want to output. Is MyString a pointer??? Jon
Now that you've fixed the missing NULL terminator, why not use
for ( i = 0; MyString[i]; i ++ ) etc
This is the exact output you will get if MyString is located in external memory at address xx4C and the memory is not connected.