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,
Within my serial receive interrupt routine I'm getting a linker warning dealing with a printf statement.
My code and the warning are shown below:
void serial_int() interrupt 4 { if(RI == 1) {
serial_data = SBUF0;
// printf("data read = \n"); printf("data read = %x\n",serial_data); } RI = 0; }
The warning:
WARNING L15: Multiple Call To Segment SEGMENT: ? PR?PRINTF?PRINTF CALLER1: ?PR?SERIAL_INT?
Why is the printf statement generating a warning?
Thanks Sparky_ Thanks
I'm going to ignore your linker warning and talk about something else.
Using printf() in an interrupt handler is seldom a good idea. On one hand, printf() is slow, which means that each interrupt will be slow, leaving little time for the main application.
Next problem is that printf() needs quite much resources.
Third problem is that printf() may not be written to be reentrant, i.e. support that you get an interrupt that calls printf() while the main loop is currently busy with another call to printf().