Go to Post Besides, all the FIRSTers that I know - are children at heart. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-02-2008, 13:24
mentorbob mentorbob is offline
Registered User
FRC #1307
 
Join Date: Feb 2008
Location: Dover, NH
Posts: 1
mentorbob is an unknown quantity at this point
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   Spotlight this post!  
Unread 10-02-2008, 16:44
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: printf() inside interrupt routine?

Quote:
Originally Posted by mentorbob View Post
Nathan,
... Most library routines are not re-entrant. ...
Bob
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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 23:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi