I have used the following code to send a display string to an RS232 port. It always worked in Keil Microvision2. Now in microvision5 it does not.
DispString (“Abcdefg\n”); Void DispString ( unsigned char *gp) { unsigned char i; For (i=0; *(gp+i) != ‘\n’; i++) { putChar (*(gp+i) ); } }
So why does the above DispString not work..?? I get no error messages. However if I change (“Abcdefg”) to (‘Abcdefg’) I get error message …. > too many characters in character literal – extra leading characters ignored.. Can anyone explain and tell me what is the correct way in #5 (and maybe why it doesn't ?) Thanks. Bhal
What, exactly, do you mean by, "does not work" ?
www.catb.org/.../smart-questions.html
What debugging have you done to find what's happening? eg, have you stepped it in the debugger?
if I change (“Abcdefg”) to (‘Abcdefg’) I get error message
Of course you do - because that's not the correct way to write strings in 'C' !
Your post shows different opening & closing quote characters - is that actually in your source code, or is it just an artefact of the forum? In your source code, you should just use the double-quote character - ASCII code 0x22
Sir, First, I do not see different opening and closing quotes ("..Your post shows different opening & closing quote characters - is that actually in your source code, or is it just an artefact of the forum?"..). I have looked carefully at my posted code.. So maybe it is an artifact of the forum.. Second, it is not true that single quotes "are not the correct way to write strings in C".... As a matter of fact, in the rest of this module, I have single quotes (e.g. putChar('a'); )and it works. i.e. I see the character a on the hyper terminal. But I want to be able to display messages which are multi character and each on is of different length and that is why i wrote this routine... It works in Microvision2 and 5 and on different processors...
As for what debugging I have done, there is nothing showing up in the hyperterminal, and the single stepping shows it is stuck @ DispString(...) line.
Perhaps you can explain why I am getting the error (... too many characters in character literal – extra leading characters ignored..)
and what to do to fix it,
rather than just say of course...
Thanks. Bhal
Please find AND READ a tutorial on C programming. Your questions suggest that you would benefit from something for absolute beginners.
View all questions in Keil forum