Hello, I have Silabs 8051f120-DK. I am making an interactive project between the MCU and a UI program written in VB.NET on a PC. The MCU receives a char and executes a procedure accordingly, i.e reading from ADC port. Right now I am trying to debug a problem that I am having and I can't continue until I resolve this. The code: https://uploadfiles.io/cfde7 (Sorry about that, too many characters)
Notice what I am doing in main.
This is what the user see: postimg.org/.../
Thanks, any enlightenment would be appreciated.
The subject is: using printf and scanf
do not provide links to code, include it in the post. I (and many others) do not load from "unknown sources"
you may want to post here community.silabs.com/.../Forum there, at least, we do not have to enter stupid capchas to reply
Can you provide a site that you trust?
this site has insert code instructions and the site above has an insert code button, use that.
REMEMBER convert tabs to spaces before inserting code
Google Drive?
If you are waiting for a single character perhaps getchar() would be better? Or qualify scanf() == 1
You could see what the other characters are that it is receiving, perhaps CR and LF?
May be you could be more selective in when you print the prompt?
printf("Enter 'r' to read volts:\n"); argsread = scanf("%c",&key); // user enters his key printf("\r\n%d %d\r\n", argsread, key); // report what you are seeing if ((argsread == 1) && (key == 'r')) ...
I'm using _getkey() function for scanf. It's seems that when I print a message after getting a key, the MCU sends the char that is already stored in SBUF (from previous scanf) and then prints the actual message in printf.
after getting a key, the MCU sends the char that is already stored in SBUF
IMPOSSIBLE!!
it's "bible time"
www.danlhenry.com/.../80C51_FAM_ARCH_1.pdf www.danlhenry.com/.../80C51_FAM_HARDWARE_1.pdf www.danlhenry.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Please take a look at the code: drive.google.com/.../view
An image of the output: drive.google.com/.../view
here you go again I (and many others) do not open attachments
at the silabs site mentioned above you can include image and code w/o using attachment
the reluctance of opening attachments is NOT related to the site, but the contents.
posting at google does not guarantee that the contents are 'clean'