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.
Greetings,
I am wanting an interrupt to occur when I receive data.
In my code - When I receive data, I set a variable and clear RI.
Then in the main part of my code I have some printf() statements.
Am I correct that a serial interupt occurs on either RI or TI being set?
Is there a way to interrupt on ONLY a receive?
My code is getting locked up. I'm thinking it's due to my printf's and interrupts.
My printf's work - when I disable interrupts.
Am I getting into problems clearing TI in my ISR - I'm guessing my printf is not complete when the code bounces back.
How should I handle interrupting on received data and using printf to display that received data?
The ISR: void serial_int() interrupt 4 {
if(TI == 1) {
TI = 0;
}
if(RI == 1)
{
RI = 0;
serial_data = SBUF0;
need_serial_port_service = 1;
key_pressed = 1;
Thanks Sparky_
Any thoughts on how to handle interrupting on a receive and still keep printf() happy?
printf() doesn't have all that much to do with this. It's your implementation of the underlying putchar support that causes the problem. You have to make that interrupt-based, too.
even more specific you need to make a buffered interrupt driven serial transmitter. Then you need to create a new version of putchar(), that puts the Tx char in that buffer.
Thanks so much!
Any chance you can point me to an example of this?
Thanks -Sparky
http://www.keil.com/download/list/c51.htm