This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Serial Interrupts / printf

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;

}

RI = 0;

TI = 0;

}

Thanks
Sparky_

0