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 writtena function to display string of characters using pointer but it shows error. can anybody what is the error in it?
void WriteString(char *Buff) { int nStringLength; int nLoop; nStringLength = strlen(Buff); for(nLoop=0;nLoop<=nStringLength;nLoop++) { SBUF = Buff(nLoop); while(!TI); TI = 0; } Delay(50); return; }
when compiling there is a error pointing the line,
SBUF = Buff(nLoop); The error is,
Error C211 : call not to a function Error C208 'function':too many actual parameters.
Using that function i couldnt see the characters transmitting in the serial port.
whereas if send a single character it can come to the serial window.
what can be problem?
"what can be problem?"
Single-step the code in the Simulator and watch what happens - That should quickly take you to an answer to your question...
My main function looks like below,
void main(void) { InitSerialPort(); WriteString("Control Genesis Power Supply"); WriteChar('m'); while(1); }
void InitSerialPort(void) { TMOD = 0x20; TH1 = 0xFD; // 19200 BAUD RATE TL1 = 0x00; SCON = 0x50; // SM0 = 0, SM1 = 1, REN = 1 TR1 = 0x01; // RUN CONTROL BIT }
After executing i can see only the character 'm' is coming in the serial port but the string is not coming.
I dont know whatis the problem. But this program runs fine with in the debugger/simulator mode.
As dan pointed it should be [ ] or alternately use SBUF= *Buff and Buff++