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
But my main problem is the understanding of why the program will not proceed to the while loop and just print the ... indefinately.
Can you post your UART init routine ?
Also, you may want to look at 1) the power-on default value of SCON and 2) the putchar() routine (which you can find in \C51\LIB).
The power-on default value for TI in SCON is 0, while putchar will wait in an endless loop while TI is 0 (since it assumes that TI==0 means that a character is currently being transmitted - which is not the case after power-on). Therefore, using putchar() without either 1) sending one character "by hand" or 2) setting TI to 1 manually will result in being stuck in and endless loop.
Just to clearify, if you add a printf above the ES = 1; row it will be executed.
Any printf below ES = 1; will not be executed. Although any printf done from the interrupt function will work fine.
I need my interrupt to not block the rest of the "show".
Although any printf done from the interrupt function will work fine.
Calling a non-reentrant, heavyweight function like printf() inside an interrupt service routine is another bad idea.