Topic : Using printf() with interrupts

Forum : 8051

Original Post
Post Information Post
June 24, 2008 - 7:59pm
Guest

On 8051's ES0 enables both Rx and Tx interrupts for UART0. I would like to receive incomings characters on interrupt while using RIDE's printf() to send text. However printf() does not work with interrupts enabled. Is there a way to do this?

regards Steven Pruzina

Replies
Post Information Post
+1
0
-1
July 26, 2008 - 4:00pm
Guest

I guess you need to write your own getkey and/or putchar routines to substitute for the default ones (ride/inc/sources/8051/rc51/putchar.a51, but they can be written in C), and an interrupt service routine to interface to it/them. I don't think there's anything intrinsically uninterruptible about printf itself. Best make the ISR simply transfer characters to a circular buffer, and getkey read from it.

And beware the problem with linking putchar we talked about before, the linker doesn't seem to recognise any pseudo-static variables that your putchar uses as being called by (eg) printf.

I'm using printf to write my LCD display via a custom putchar OK.

Tim Jackson