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.
Hi everyone!
I'm a n00b to microcontroller programming so have patience with me :)
The mission is to handle some uart (rs232) communication, both rx and tx. My part is a small module going into a rest of the software already developed.
The issue is the following: When I use serial ISR it seems to not go into the "main while loop" (which is required).
(I've also tried to poll my self but reliability seems somewhat unstable, loosing a byte here and there)
I've tried the simplest demo/test programs and if I for instance use a printf in the while loop, it will not reach it as soon as ES = 1.
Is it just that any printf will not issue an interrupt and hence no output to my terminal? At the moment I can not test my module with the rest of the software so I'm a bit in the blind here, well could of course try to blink a led or something... but I reacon a answer from here is faster and more reliable :)
Thanks in advance
/Mike
Is it just that any printf will not issue an interrupt and hence no output to my terminal?
If you look at the putchar() function (which is used by the printf() function), you should find that it actually uses polling. It's usually a bad idea to mix interrupt-driven and polling operation for a peripheral. You may need to adapt the putchar() function to operate the UART with interrupts.
"using printf() and using interrupt-driven operation on the UART at the same time is most likely a bad idea."
Not at all!
There is absolutely no reason whatsoever why you should not use printf with interrupt-driven serial IO provided you make the necessary changes to putchar() - See: http://www.keil.com/support/man/docs/c51/c51_printf.htm
See also: http://www.keil.com/support/man/docs/c51/c51_putchar.htm http://www.keil.com/support/man/docs/c51/c51_lib_source.htm
It's all clearly illustrated in the following Keil examples: http://www.keil.com/download/docs/200.asp http://www.keil.com/download/docs/71.asp You can use this code directly in your application - no need to re-invent the wheel!