CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Can I use putchar in ISR?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chen
Guest







Can I use putchar in ISR?
PostPosted: Thu Jun 26, 2003 3:00 pm     Reply with quote

How about printf?

If I use printf ("hello world"), will printf wait until all bytes transmitted?

Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515586
R.J.Hamlett
Guest







Re: Can I use putchar in ISR?
PostPosted: Thu Jun 26, 2003 3:38 pm     Reply with quote

:=How about printf?
:=
:=If I use printf ("hello world"), will printf wait until all bytes transmitted?
:=
:=Thanks
The 'answer', depends on whether you want to use the routines outside the interrupt as well?. If you do, then the compiler, will automatically disable interrupts round the code, which will result in long periods with the interrupts disabled.
The best solution, is instead to write your own interrupt driven I/O handler (there have been examples published in the past on this group, and is at least one similar example in the CCS samples).
Then you can use the code to write to the buffer, both inside the interrupts and outside (with the same caveat that interrupts will then be disabled in this code), but the actual transfer to the buffer will be relatively quick, so preventing too many problems.
Generally, 'printf', with any formatting, is a very slow routine (so you will then run into the general point that code should be kept short in the interrupt handler if possible). However transferring single characters to a buffer is not too bad.
All the CCS I/O routines will wait till the characters have all been transferred to the UART (if using the hardware RS232), but with the hardware forms, not till the transmission is complete (there will still be a couple of characters 'in transit'.
Generally, it is much simpler and better to avoid this unless necessary.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515587
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group