<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Timer2 - Printf function</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/37550/timer2---printf-function</link><description> 
Hi, 

 
Sorry for the mistake. Here is the question again: 

 
I need to use 89C52 timer2 counter function. However, when I use
the timer2, I cannot use printf function to debug my program, that
is, no display output. However, printf function works</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/51293?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 18:56:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:902755f4-a7fa-4324-8951-23c76761f467</guid><dc:creator>Ed Lau</dc:creator><description>&lt;p&gt;&lt;p&gt;
I am using Keil uVision 3 - Keil Monitor-51 to simulate/debug my
program. Keil using TX/RX pin for the serial I/O to download the
program. In that case, they already config baud rate generator.&lt;/p&gt;

&lt;p&gt;
I don&amp;#39;t know why printf cannot work under timer2 counter
environment, but working under timer0,timer1 environment using Keil
Monitor-51?&lt;/p&gt;

&lt;p&gt;
My mistake of using Keil Monitor or malfuntion of my hardware?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/88702?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 12:21:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:48915c1a-dfc3-4a69-9e84-3cd6706bc2a5</guid><dc:creator>Per Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
If you want to use printf() in a configuration where you don&amp;#39;t
have a baudrate generator, then you have to bit-blit some I/O pins to
emulate the UART. Not funny at all. And really dreadful if you need
to be able to receive data too.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/51294?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 12:03:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:55bc061a-31d7-4201-bad0-4a2b057f55ee</guid><dc:creator>Ed Lau</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for all info.&lt;/p&gt;

&lt;p&gt;
I am not intent to use printf in timer2 ISR but in the main to
debug my program.&lt;/p&gt;

&lt;p&gt;
Any method to get this done or forget printf in timer2
environment?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/88701?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 10:43:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:90dae380-372a-48c9-adb3-9e6a834f5195</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
It&amp;#39;s not so much that you &lt;i&gt;&lt;b&gt;can&amp;#39;t&lt;/b&gt;&lt;/i&gt; use printf in an ISR
- you can do it, and you &lt;i&gt;&lt;b&gt;might&lt;/b&gt;&lt;/i&gt; get away with it...&lt;/p&gt;

&lt;p&gt;
The trouble is:&lt;/p&gt;

&lt;p&gt;
* printf is a huge function - and that&amp;#39;s Bad for an ISR;&lt;/p&gt;

&lt;p&gt;
* the default printf uses polled output - and that&amp;#39;s Bad for an
ISR;&lt;/p&gt;

&lt;p&gt;
* printf is not reentrant - and that&amp;#39;s &lt;i&gt;&lt;b&gt;really&lt;/b&gt;&lt;/i&gt; bad if
you also call it from main!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/88703?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 10:40:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f24b3b69-ec3b-4f69-b26d-ccdaa68e3be1</guid><dc:creator>stephen phillips</dc:creator><description>&lt;p&gt;&lt;p&gt;
Unless I am missing something is not T2 or T1 to be dedicated as a
baud rate generated for serial output? If you are using printf
through the serial port (which is the default behavior with putchar).
This means you either cannot use T1 or you cannot use T2 as a regular
timer and use the serial port. If you intend to use both those timers
no serial port, otherwise you must select one timer to generate the
baud clock. Some variants of the C51 allow external baud rate
generation I believe.&lt;/p&gt;

&lt;p&gt;
Stephen&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/51292?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 10:21:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ef76fc59-beb9-4927-b2b4-83b34ead8146</guid><dc:creator>Ed Lau</dc:creator><description>&lt;p&gt;&lt;p&gt;
Erik, sorry for the confusion. My questions are:&lt;/p&gt;

&lt;p&gt;
1. Timer2 cannot use printf in ISR. Can I use printf in the main
program?&lt;/p&gt;

&lt;p&gt;
2. Why timer0 and timer1 can use printf in the main program and
ISR?&lt;/p&gt;

&lt;p&gt;
Once again, thanks for your prompt reply.&lt;/p&gt;

&lt;p&gt;
Ed&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/88704?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 09:58:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fee449be-ccc1-42b2-94b3-5b951de2e7c7</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
I posted &lt;i&gt;are you trying to do a prinf in an ISR?, that does not
work&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
you reply &lt;i&gt;I cannot use the printf in the ISR&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
what&amp;#39;s the issue?&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/51297?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 09:21:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b01ffc79-57b3-4cc8-9420-9067e550b25e</guid><dc:creator>Ed Lau</dc:creator><description>&lt;p&gt;&lt;p&gt;
I wrote timer0, timer1 and timer2 counter all in one program. When
I invoke timer0, or timer1, I can use printf in the main program and
the ISR. However, when I invoke timer2, I cannot use the printf in
the ISR and the main program. System not hang, but just ignore to
display.&lt;/p&gt;

&lt;p&gt;
Any idea?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer2 - Printf function</title><link>https://community.arm.com/thread/51289?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2007 08:59:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:798b9a72-b72b-4b3f-ae78-b02a5ff9902e</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
are you trying to do a prinf in an ISR?, that does not work&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>