|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: printf() inside interrupt routine?
Nathan,
It wouldn't be a good idea to call a library routine like printf from inside an interrupt, even if the interrupt only happened every second. Most library routines are not re-entrant. If you were in the middle of a printf when the interrupt occurred, calling printf from inside the interrupt would mess up the printf in progress. Bob |
|
#2
|
|||
|
|||
|
Re: printf() inside interrupt routine?
hmmm, I checked the MCC 18 library and found a couple routines that are non-reentrant as they appear that they might use some globals (e.g. strtokpgmram), but the majority of the library, including print/put/etc., appears to be re-entrant friendly by using only auto variables. The compiler will use .tmpdata and other managed resources, per usual, but interrupt routines should be saving the appropriate ones as needed already.
Do you know for certain that the library is non-reentrant? That would be good info to know as there are many library calls used that are not directly called by the user, like FXM3232 which is used for long x long multiplication. Its still not a good idea to call printf() from within an interrupt routine due to the time delays associated with outputing the formated data, but not being re-entrant doesn't appear to be a reason in this case. I easily could be wrong, but looking at printf, vprintf, etc down the call train didn't reveal any obvious globals being referenced that would make the routine non-reentrant. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Routine declaration syntax error (Or: Where's wlado?) | Astronouth7303 | Programming | 15 | 24-03-2004 05:51 |
| printf isn't printf-ing. Help! | Meandmyself | Programming | 14 | 15-02-2004 16:27 |
| Pre-Match/Post- Match Pit Routine | Mark_lyons | General Forum | 14 | 31-03-2002 15:19 |
| Master uP Initialization Routine | Ulibrium | Technical Discussion | 5 | 24-01-2002 16:43 |