![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
chen Guest
|
Can I use putchar in ISR? |
Posted: Thu Jun 26, 2003 3:00 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
R.J.Hamlett Guest
|
Re: Can I use putchar in ISR? |
Posted: Thu Jun 26, 2003 3:38 pm |
|
|
:=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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|