<?xml version="1.0" encoding="utf-8"?>
				<!-- generator="e107" -->
				<!-- content type="Forum / topic" -->
				<rss  version="2.0">
				<channel>
				<title>8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes : Forum / topic</title>
				<link>http://www.8051projects.net/</link>
				<description>Learn to make simple microcontroller projects, pic, 8051, avr and arm projects. download 8051 projects, tutorials, libraries, sample codes. join the microcontroller discussion forum and ask doubts regarding electronics. the best source for 8051 over internet.</description>

<language>en-gb</language>
				<copyright>2008 Rickey's World</copyright>
				<managingEditor>contact@nospam.com (Ajay Bhargav)</managingEditor>
				<webMaster>contact@nospam.com (Ajay Bhargav)</webMaster>
				<pubDate>Thu, 08 Jan 2009 23:24:15 -0800</pubDate>
				<lastBuildDate>Thu, 08 Jan 2009 23:24:15 -0800</lastBuildDate>
				<docs>http://backend.userland.com/rss</docs>
				<generator>e107 (http://e107.org)</generator>
				<ttl>60</ttl>
				<textInput>
				<title>Search</title>
				<description>Search 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes</description>
				<name>query</name>
				<link>http://www.8051projects.net/search.php</link>
				</textInput>
						<item>
						<title>IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<strong class='bbcode bold'><span style='font-size:10px'>suppose in an industrial application  we have to controll some events ,which are time dependent, using microcontroller.<br /><br />the problem is like : there are 10 deveces  . and these devices runs for 10 second (say) if it gets an input <br />signal.(note : all these 10 devices gets input signals randomly i.e. some times 2 devices may get input signal<br /> ,sometimes 4 or 5 or 8 or all 10 etc.)<br />now suppose  if in first time slot (i.e. 10 second) 5 devices are running  and before the end of first time slot <br />another 2 devices gets input signal  .... and so on ...<br /><br />how would u  controll it using single microcontroller .</span></strong>]]></description>
<pubDate>Sat, 28 Jun 2008 12:32:47 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[Would the devices go off after 10s by themselves or does the micro have to switch them off after the time slot elapses?]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 28 Jun 2008 20:27:44 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<br /> hi caze,<br /><br />i don't see where you are having problem, can you be more clear<br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 28 Jun 2008 19:02:47 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[hi Caze<br /><br />here  comes the fundamental RTOS functionalities Semaphores mutex and mutual exclusion.<br />by using one or more than one or all of the above techniques we can <br />1. set priorities to the Tasks<br />2. make other tasks wait for the previous o complete, without missing input signals.<br />3. store the sequence of inputs in page tables (as in your computer)  and then proccess accordingly may be by <br />a. FIFO or Priority basis or both.<br /> <br /><br />that is the reason most of the industrial automation tenders  nowadays  necessarily mention RTOS as the main part of the product.<br /><br />i believe using RTOS will solve the problem, still if ur uController doesnt support it..  u can make the necessary routines  yourselves.<br /> <img src='http://www.8051projects.net/e107_images/emotes/yahoo/103.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 28 Jun 2008 22:57:19 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[hi @  sashijoseph,<br /><br />                          devices has to be stoped by microcontroller itself.<br />   <br /> <br /> <br />  <br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 29 Jun 2008 05:28:41 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[hi shyam,<br />                great idea. but i guess writing routine for 8051 will be too lengthy and tedious work .<br /><br />is it possible to]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 29 Jun 2008 05:32:28 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[yes it can be written   <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' /> <br /><br />u will find some keil examples with RTX51.<br />a little effort and u can get the source of the kernel too <img src='http://www.8051projects.net/e107_images/emotes/yahoo/3.gif' alt='' style='vertical-align:middle; border:0' /> <br /><br />ammend it according to ur need and u'll get the solution..<br />here take a look this is a 51 code!<br /><br /> <div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; TRAFFIC.C: &nbsp;Traffic Light Controller using the C-51 COMPILER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><br /><span style="color: #993333;">char</span> code menu<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> =<br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;+***** TRAFFIC LIGHT CONTROLLER using C51 and RTX-51 tiny *****+<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| This program is a simple Traffic Light Controller. &nbsp;Between &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| start time and end time the system controls a traffic light &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| with pedestrian self-service. &nbsp;Outside of this time range &nbsp; &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| the yellow caution lamp is blinking. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;+ command -+ syntax -----+ function ---------------------------+<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| Display &nbsp;| D &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | display times &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| Time &nbsp; &nbsp; | T hh:mm:ss &nbsp;| set clock time &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| Start &nbsp; &nbsp;| S hh:mm:ss &nbsp;| set start time &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;| End &nbsp; &nbsp; &nbsp;| E hh:mm:ss &nbsp;| set end time &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />&nbsp; &nbsp;<span style="color: #ff0000;">&quot;+----------+-------------+-------------------------------------+<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br /><br /><br /><span style="color: #339933;">#include &lt;reg52.h&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* special function registers 8052 &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #339933;">#include &lt;rtx51tny.h&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* RTX-51 tiny functions &amp; defines &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #339933;">#include &lt;stdio.h&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* standard I/O .h-file &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #339933;">#include &lt;ctype.h&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* character functions &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #339933;">#include &lt;string.h&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* string and memory functions &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><br /><br /><span style="color: #000000; font-weight: bold;">extern</span> getline <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> idata *, <span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span>; &nbsp;<span style="color: #808080; font-style: italic;">/* external function: &nbsp;input line &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #000000; font-weight: bold;">extern</span> serial_init <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* external function: &nbsp;init serial UART */</span><br /><br /><span style="color: #339933;">#define INIT &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* task number of task: &nbsp;init &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #339933;">#define COMMAND &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* task number of task: &nbsp;command &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #339933;">#define CLOCK &nbsp; &nbsp; 2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* task number of task: &nbsp;clock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #339933;">#define BLINKING &nbsp;3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* task number of task: &nbsp;blinking &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #339933;">#define LIGHTS &nbsp; &nbsp;4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* task number of task: &nbsp;signal &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #339933;">#define KEYREAD &nbsp; 5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* task number of task: &nbsp;keyread &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #339933;">#define GET_ESC &nbsp; 6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* task number of task: &nbsp;get_escape &nbsp; &nbsp; */</span><br /><br /><span style="color: #993333;">struct</span> time &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* structure of the time record &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> hour; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* hour &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> min; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* minute &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> sec; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* second &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #66cc66;">&#125;</span>;<br /><br /><span style="color: #993333;">struct</span> time ctime = <span style="color: #66cc66;">&#123;</span> <span style="color: #cc66cc;">12</span>, &nbsp;<span style="color: #cc66cc;">0</span>, &nbsp;<span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#125;</span>; &nbsp; <span style="color: #808080; font-style: italic;">/* storage for clock time values &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #993333;">struct</span> time start = <span style="color: #66cc66;">&#123;</span> &nbsp;<span style="color: #cc66cc;">7</span>, <span style="color: #cc66cc;">30</span>, &nbsp;<span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#125;</span>; &nbsp; <span style="color: #808080; font-style: italic;">/* storage for start time values &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #993333;">struct</span> time end &nbsp; = <span style="color: #66cc66;">&#123;</span> <span style="color: #cc66cc;">18</span>, <span style="color: #cc66cc;">30</span>, &nbsp;<span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#125;</span>; &nbsp; <span style="color: #808080; font-style: italic;">/* storage for end &nbsp; time values &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><br />sbit &nbsp;red &nbsp; &nbsp;= P1^<span style="color: #cc66cc;">2</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* I/O Pin: &nbsp;red &nbsp; &nbsp;lamp output &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />sbit &nbsp;yellow = P1^<span style="color: #cc66cc;">1</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* I/O Pin: &nbsp;yellow lamp output &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />sbit &nbsp;green &nbsp;= P1^<span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* I/O Pin: &nbsp;green &nbsp;lamp output &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />sbit &nbsp;stop &nbsp; = P1^<span style="color: #cc66cc;">3</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* I/O Pin: &nbsp;stop &nbsp; lamp output &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />sbit &nbsp;walk &nbsp; = P1^<span style="color: #cc66cc;">4</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* I/O Pin: &nbsp;walk &nbsp; lamp output &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />sbit &nbsp;key &nbsp; &nbsp;= P1^<span style="color: #cc66cc;">5</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* I/O Pin: &nbsp;self-service key input &nbsp; &nbsp; */</span><br /><br /><span style="color: #993333;">char</span> idata <span style="color: #000000; font-weight: bold;">inline</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#93;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* storage for command input line &nbsp; &nbsp; &nbsp; */</span><br /><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;Task 0 'init': Initialize &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #993333;">void</span> init <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> _task_ INIT &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* program execution starts here &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; serial_init <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* initialize the serial interface &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; os_create_task <span style="color: #66cc66;">&#40;</span>CLOCK<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* start clock task &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; os_create_task <span style="color: #66cc66;">&#40;</span>COMMAND<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* start command task &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; os_create_task <span style="color: #66cc66;">&#40;</span>LIGHTS<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* start lights task &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; os_create_task <span style="color: #66cc66;">&#40;</span>KEYREAD<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* start keyread task &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; os_delete_task <span style="color: #66cc66;">&#40;</span>INIT<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* stop init task (no longer needed) &nbsp; &nbsp;*/</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br />bit display_time = <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* flag: &nbsp;signal cmd state display_time */</span><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;Task 2 'clock' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #993333;">void</span> clock <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> &nbsp;_task_ CLOCK &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* clock is an endless loop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>++ctime.<span style="color: #202020;">sec</span> == <span style="color: #cc66cc;">60</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* calculate the second &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; ctime.<span style="color: #202020;">sec</span> = <span style="color: #cc66cc;">0</span>;<br />&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>++ctime.<span style="color: #202020;">min</span> == <span style="color: #cc66cc;">60</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* calculate the minute &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; ctime.<span style="color: #202020;">min</span> = <span style="color: #cc66cc;">0</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>++ctime.<span style="color: #202020;">hour</span> == <span style="color: #cc66cc;">24</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* calculate the hour &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ctime.<span style="color: #202020;">hour</span> = <span style="color: #cc66cc;">0</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>display_time<span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* if command_status == display_time &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; os_send_signal <span style="color: #66cc66;">&#40;</span>COMMAND<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* signal to task command: time changed */</span><br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_IVL, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* wait interval: &nbsp;1 second &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><span style="color: #993333;">struct</span> time rtime; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* temporary storage for entry time &nbsp; &nbsp; */</span><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;readtime: convert line input to time values &amp; store in rtime &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br />bit readtime <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> idata *buffer<span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> args; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* number of arguments &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><br />&nbsp; rtime.<span style="color: #202020;">sec</span> = <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* preset second &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; args = sscanf <span style="color: #66cc66;">&#40;</span>buffer, <span style="color: #ff0000;">&quot;%bd:%bd:%bd&quot;</span>, &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* scan input line for &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&rtime.<span style="color: #202020;">hour</span>, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* hour, minute and second &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&rtime.<span style="color: #202020;">min</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&rtime.<span style="color: #202020;">sec</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp;<br />&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>rtime.<span style="color: #202020;">hour</span> &gt; <span style="color: #cc66cc;">23</span> &nbsp;|| &nbsp;rtime.<span style="color: #202020;">min</span> &gt; <span style="color: #cc66cc;">59</span> &nbsp;|| &nbsp;<span style="color: #808080; font-style: italic;">/* check for valid inputs &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; rtime.<span style="color: #202020;">sec</span> &gt; <span style="color: #cc66cc;">59</span> &nbsp; || &nbsp;args &lt; <span style="color: #cc66cc;">2</span> &nbsp; &nbsp; &nbsp; &nbsp;|| &nbsp;args == EOF<span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>*** ERROR: INVALID TIME FORMAT<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><br /><span style="color: #339933;">#define ESC &nbsp;0x1B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* ESCAPE character code &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><br />bit &nbsp; escape; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* flag: mark ESCAPE character entered &nbsp;*/</span><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;Task 6 'get_escape': check if ESC (escape character) was entered &nbsp; &nbsp;*/</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #993333;">void</span> get_escape <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> _task_ GET_ESC &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* endless loop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_getkey <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == ESC<span style="color: #66cc66;">&#41;</span> &nbsp;escape = <span style="color: #cc66cc;">1</span>; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* set flag if ESC entered &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>escape<span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* if escape flag send signal &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; os_send_signal <span style="color: #66cc66;">&#40;</span>COMMAND<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* to task 'command' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;Task 1 'command': command processor */</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #993333;">void</span> command <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> _task_ COMMAND &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> i;<br /><br />&nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span>menu<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* display command menu &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* endless loop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Command: &quot;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* display prompt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; getline <span style="color: #66cc66;">&#40;</span>&inline, <span style="color: #993333;">sizeof</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">inline</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* get command line input &nbsp; &nbsp; &nbsp;*/</span><br /><br />&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;">0</span>; <span style="color: #000000; font-weight: bold;">inline</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> != <span style="color: #cc66cc;">0</span>; i++<span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* convert to uppercase &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">inline</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = toupper<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">inline</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br /><br />&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;">0</span>; <span style="color: #000000; font-weight: bold;">inline</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> == <span style="color: #ff0000;">' '</span>; i++<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* skip blanks &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br /><br />&nbsp; &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">inline</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* proceed to command function */</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'D'</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* Display Time Command &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Start Time: %02bd:%02bd:%02bd &nbsp; &nbsp;&quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;End Time: %02bd:%02bd:%02bd<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;start.<span style="color: #202020;">hour</span>, start.<span style="color: #202020;">min</span>, start.<span style="color: #202020;">sec</span>,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end.<span style="color: #202020;">hour</span>, &nbsp; end.<span style="color: #202020;">min</span>, &nbsp; end.<span style="color: #202020;">sec</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;type ESC to abort<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; os_create_task <span style="color: #66cc66;">&#40;</span>GET_ESC<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* ESC check in display loop &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; escape = <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* clear escape flag &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; display_time = <span style="color: #cc66cc;">1</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* set display time flag &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; os_clear_signal <span style="color: #66cc66;">&#40;</span>COMMAND<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* clear pending signals &nbsp; &nbsp; &nbsp; */</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>!escape<span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* while no ESC entered &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Clock Time: %02bd:%02bd:%02bd<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span>, &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* display time &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ctime.<span style="color: #202020;">hour</span>, ctime.<span style="color: #202020;">min</span>, ctime.<span style="color: #202020;">sec</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_SIG, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for time change or ESC */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; os_delete_task <span style="color: #66cc66;">&#40;</span>GET_ESC<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* ESC check not longer needed */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; display_time = <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* clear display time flag &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span>;<br /><br />&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'T'</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* Set Time Command &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>readtime <span style="color: #66cc66;">&#40;</span>&inline<span style="color: #66cc66;">&#91;</span>i<span style="color: #cc66cc;">+1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* read time input and &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ctime.<span style="color: #202020;">hour</span> = rtime.<span style="color: #202020;">hour</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* store in 'ctime' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ctime.<span style="color: #202020;">min</span> &nbsp;= rtime.<span style="color: #202020;">min</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ctime.<span style="color: #202020;">sec</span> &nbsp;= rtime.<span style="color: #202020;">sec</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span>;<br /><br />&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'E'</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* Set End Time Command &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>readtime <span style="color: #66cc66;">&#40;</span>&inline<span style="color: #66cc66;">&#91;</span>i<span style="color: #cc66cc;">+1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* read time input and &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end.<span style="color: #202020;">hour</span> = rtime.<span style="color: #202020;">hour</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* store in 'end' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end.<span style="color: #202020;">min</span> &nbsp;= rtime.<span style="color: #202020;">min</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end.<span style="color: #202020;">sec</span> &nbsp;= rtime.<span style="color: #202020;">sec</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span>;<br /><br />&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'S'</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* Set Start Time Command */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>readtime <span style="color: #66cc66;">&#40;</span>&inline<span style="color: #66cc66;">&#91;</span>i<span style="color: #cc66cc;">+1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* read time input and &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start.<span style="color: #202020;">hour</span> = rtime.<span style="color: #202020;">hour</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* store in 'start' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start.<span style="color: #202020;">min</span> &nbsp;= rtime.<span style="color: #202020;">min</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start.<span style="color: #202020;">sec</span> &nbsp;= rtime.<span style="color: #202020;">sec</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span>;<br /><br />&nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">default</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Error Handling &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span>menu<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* display command menu &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span>;<br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> &nbsp;<br />&nbsp; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;signalon: check if clock time is between start and end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br />bit signalon <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><br />&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>memcmp <span style="color: #66cc66;">&#40;</span>&start, &end, <span style="color: #993333;">sizeof</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">struct</span> time<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &lt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>memcmp <span style="color: #66cc66;">&#40;</span>&start, &ctime, <span style="color: #993333;">sizeof</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">struct</span> time<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &lt; <span style="color: #cc66cc;">0</span> &nbsp;&&<br />&nbsp; &nbsp; &nbsp; &nbsp; memcmp <span style="color: #66cc66;">&#40;</span>&ctime, &end, &nbsp; <span style="color: #993333;">sizeof</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">struct</span> time<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &lt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; <span style="color: #b1b100;">else</span> &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>memcmp <span style="color: #66cc66;">&#40;</span>&end, &nbsp; &ctime, <span style="color: #993333;">sizeof</span> <span style="color: #66cc66;">&#40;</span>start<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &gt; <span style="color: #cc66cc;">0</span> &nbsp;&&<br />&nbsp; &nbsp; &nbsp; &nbsp; memcmp <span style="color: #66cc66;">&#40;</span>&ctime, &start, <span style="color: #993333;">sizeof</span> <span style="color: #66cc66;">&#40;</span>start<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &gt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* signal off, blinking on &nbsp; &nbsp; */</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;Task 3 'blinking': runs if current time is outside start &amp; end time */</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #993333;">void</span> blinking <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> _task_ BLINKING &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* blink yellow light &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; red &nbsp; &nbsp;= <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* all lights off &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; yellow = <span style="color: #cc66cc;">0</span>;<br />&nbsp; green &nbsp;= <span style="color: #cc66cc;">0</span>;<br />&nbsp; stop &nbsp; = <span style="color: #cc66cc;">0</span>;<br />&nbsp; walk &nbsp; = <span style="color: #cc66cc;">0</span>;<br /><br />&nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* endless loop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; yellow = <span style="color: #cc66cc;">1</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* yellow light on &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 150 ticks &nbsp;*/</span><br />&nbsp; &nbsp; yellow = <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* yellow light off &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 150 ticks &nbsp;*/</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>signalon <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* if blinking time over &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; &nbsp; os_create_task <span style="color: #66cc66;">&#40;</span>LIGHTS<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* start lights &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; os_delete_task <span style="color: #66cc66;">&#40;</span>BLINKING<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* and stop blinking &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp;Task 4 'lights': executes if current time is between start &amp; end time */</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #993333;">void</span> lights <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> _task_ LIGHTS &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* traffic light operation &nbsp; &nbsp; */</span><br />&nbsp; red &nbsp; &nbsp;= <span style="color: #cc66cc;">1</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* red &amp; stop lights on &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; yellow = <span style="color: #cc66cc;">0</span>;<br />&nbsp; green &nbsp;= <span style="color: #cc66cc;">0</span>;<br />&nbsp; stop &nbsp; = <span style="color: #cc66cc;">1</span>;<br />&nbsp; walk &nbsp; = <span style="color: #cc66cc;">0</span>;<br />&nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* endless loop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 150 ticks */</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!signalon <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* if traffic signal time over */</span><br />&nbsp; &nbsp; &nbsp; os_create_task <span style="color: #66cc66;">&#40;</span>BLINKING<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* start blinking &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; os_delete_task <span style="color: #66cc66;">&#40;</span>LIGHTS<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* stop lights &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; yellow = <span style="color: #cc66cc;">1</span>;<br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 150 ticks */</span><br />&nbsp; &nbsp; red &nbsp; &nbsp;= <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* green light for cars &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; yellow = <span style="color: #cc66cc;">0</span>;<br />&nbsp; &nbsp; green &nbsp;= <span style="color: #cc66cc;">1</span>;<br />&nbsp; &nbsp; os_clear_signal <span style="color: #66cc66;">&#40;</span>LIGHTS<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">200</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 200 ticks */</span><br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO + K_SIG, <span style="color: #cc66cc;">250</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout &amp; signal &nbsp; */</span><br />&nbsp; &nbsp; yellow = <span style="color: #cc66cc;">1</span>;<br />&nbsp; &nbsp; green &nbsp;= <span style="color: #cc66cc;">0</span>;<br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 150 ticks */</span><br />&nbsp; &nbsp; red &nbsp; &nbsp;= <span style="color: #cc66cc;">1</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* red light for cars &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; yellow = <span style="color: #cc66cc;">0</span>;<br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">150</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 150 ticks */</span><br />&nbsp; &nbsp; stop &nbsp; = <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* green light for walkers &nbsp; &nbsp; */</span> &nbsp; &nbsp;<br />&nbsp; &nbsp; walk &nbsp; = <span style="color: #cc66cc;">1</span>;<br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">250</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 250 ticks */</span><br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">250</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 250 ticks */</span><br />&nbsp; &nbsp; stop &nbsp; = <span style="color: #cc66cc;">1</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* red light for walkers &nbsp; &nbsp; &nbsp; */</span> &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; walk &nbsp; = <span style="color: #cc66cc;">0</span>;<br />&nbsp; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #808080; font-style: italic;">/* &nbsp; &nbsp; &nbsp; &nbsp;Task 5 'keyread': process key stroke from pedestrian push button &nbsp; &nbsp;*/</span><br /><span style="color: #808080; font-style: italic;">/******************************************************************************/</span><br /><span style="color: #993333;">void</span> keyread <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> _task_ KEYREAD &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* endless loop &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>key<span style="color: #66cc66;">&#41;</span> &nbsp;<span style="color: #66cc66;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">/* if key pressed &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; os_send_signal <span style="color: #66cc66;">&#40;</span>LIGHTS<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* send signal to task lights &nbsp;*/</span><br />&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp; os_wait <span style="color: #66cc66;">&#40;</span>K_TMO, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* wait for timeout: 2 ticks &nbsp; */</span><br />&nbsp; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br />&nbsp;</div></div>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 29 Jun 2008 08:37:38 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[@Caze<br />Shyam's method is elegant and the correct way to go.<br /><br />But you could also use the 8051's 2 timers and 8 external timers(2xLM558) to control all 10 devices.The micro would poll 10 input pins continuously and trigger the timers whenever it detects an input.<br />Would,by any chance, a device already triggered and yet to complete it's 10s,get another input signal?]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 29 Jun 2008 23:09:21 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[i feel its no more a challenge if we used external analog timers, in such case we don't need the micro at all because the input signals can trigger the timers which are hard wired (RC network) for 10 sec delay. <br /><br /> the Job can be done without using external timers and using only one internal timer of 8051. after a lot of thought process i have come up with the following approach:<br /><br /><br />1) wire 10 pins on micro as inputs <br /><br />2) load timer0 with 50 milliSec values and start timer0<br /><br />3) wire  External interrupt(EX0) pin to all the 10 inputs with help of diodes in such a way that when any of the 10 inputs are received the EX0 pin along with the input pin/s is brought low( logic 0).<br /><br />4) in the External Int. ISR check which pin/s are grounded and set a flag/s for that particular input pin/s and give output/s (start the device/s)<br /><br />5) in the timer0 ISR  declare 10 counters (use registers/variables) check which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s  and reti continue till you reach 200 decimal ( 50mSec X 200 times = 10secs) once the counters reach 200 then stop the device and clear the flag/s<br /><br />6) even when some devices are running and some other new device/s is triggered the counter for that particular new device is also incremented along with the old running ones<br /><br />7) all the checking and control is done in ISRs of External int.0 and timer int.0<br /><br />8) time required for overhead instructions may cause slight delay and therefore normal 12 cycle 8051 clocked @ 12Mhz or 24 Mhz should be avoided for tasks like theses one should use the world's fastest 8051 " DS89C450" clocked at 24Mhz which is 10 times faster than normal 8051 and each instruction takes 40-45 nanosecs and task can be completed with near accuracy.<br /><br />9) if both the Ex0 interrupt and 50mSec timer int. occur at the same time,by default  first the EX0 is serviced followed by timer int.<br /><br />10) the tick time of 50 msec can be reduced  to say 20msec but to get 10 sec delay we would require to count 500 interrupts but the 8 bit counter can count max upto 255D<br /><br />if interested i can write the code in asm and post it here.<br /><br /><br />Arun<br /><br /><br /><br /><br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 01 Jul 2008 08:48:30 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<div class='quote_top'>Arun Kumar V wrote ...</div><div class='quote'>3) wire External interrupt(EX0) pin to all the 10 inputs with help of diodes in such a way that when any of the 10 inputs are received the EX0 pin along with the input pin/s is brought low( logic 0).<br /></div><br />ORing the inputs will be better <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 01 Jul 2008 23:16:53 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[^^but then which of the 10 inputs caused the interrupt wouldn't be traceable.I think that's why Arun has ORed the inputs to the INT pin(with diodes) and simultaneously used parallel IO for tracing the source of the interrupt.<br /><br />Very thoughtful Arun.]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 02 Jul 2008 20:15:43 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[I think that is a near perfect solution for the problem i woud say by arun. <br /> <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' />  <br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 02 Jul 2008 20:32:39 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[hi @ arun ,<br /><br />                   thanks a lot .......<br /><br />                  and ill be so thankful to u if u can post asm program here .]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 04 Jul 2008 11:15:49 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<br /><br />Sorry for late reply, was on a short trip.<br /><br />Thank you SJ and Pdi33 !<br /><br />caze -  i'll post the asm code and schematic  today <br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 06 Jul 2008 19:14:09 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[hello caze,<br /><br />as promised here's my code and schematic, i have written for 8 I/Os your task is to further increase it to 10 I/Os (its easy after you go thru the code)  -  Enjoy !<br /><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_final.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_final_.jpg' class='bbcode' alt='' width='500' height='333'  /></a><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_working.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_working_.jpg' class='bbcode' alt='' width='500' height='326'  /></a><br /><br /><br /><br />: code deleted by Arun<br /><br /><br /><br /><br />i have simulated and tested the code using Ds89C430 and it works well !<br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Mon, 07 Jul 2008 18:46:09 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[wow! <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' /> <br /><br />how bout starting programming competetions?<br /><br />I am not sure how good it will be.. but its gonna be fun..]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 08 Jul 2008 08:15:14 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<br /><br />  Sure, Why not ?............... <br /><br /><br /><br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 08 Jul 2008 09:16:07 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[nice idea ajay, <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />  <br />would really tickle our old grey cells.. <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' />  and help a few newcomers in many ways.<br />when do we start? <img src='http://www.8051projects.net/e107_images/emotes/yahoo/3.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 09 Jul 2008 07:39:05 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' /> <br />every competition needs a judge...<br />i believe we can help each other out.. for sure...<br />but to judge who is better wud not be that easy <img src='http://www.8051projects.net/e107_images/emotes/yahoo/10.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 09 Jul 2008 08:26:00 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[wisely said shyam.  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />  <br /><br />hmmm, too many offtopic posts here i think. <img src='http://www.8051projects.net/e107_images/emotes/yahoo/3.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Wed, 09 Jul 2008 20:05:17 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[Well..<br />I have answer to that too <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' /> <br /><br />Competitions will go like this..<br /><br />1. Problem will be post on forum and entries will be accepted till a fixed date<br />2. After entries are received, A new thread will be created<br />3. all entries will be displayed and we will have voting on the basis of logic/code efficiency<br />4. After voting date is over. We will have our winner <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' /> <br /><br />>> We have to promise ourself to vote for the best <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Thu, 10 Jul 2008 06:57:45 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[that would be nice. but will it cover all possible forum topics ? AVR/8051/PIC/VB. <br />i.e. will there be individual probems posted for each forum heading?.<br />anyways, looks very promising and attractive. <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Thu, 10 Jul 2008 07:49:02 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<div class='quote_top'>Arun Kumar V wrote ...</div><div class='quote'><br />hello caze,<br /><br />as promised here's my code and schematic, i have written for 8 I/Os your task is to further increase it to 10 I/Os (its easy after you go thru the code)  -  Enjoy !<br /><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_final.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_final_.jpg' class='bbcode' alt='' width='500' height='333'  /></a><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_working.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_working_.jpg' class='bbcode' alt='' width='500' height='326'  /></a><br /><br /><br /><br />: code deleted by Arun<br /><br /><br /><br /><br />i have simulated and tested the code using Ds89C430 and it works well !<br /><br /><br />Arun<br /></div><br /><br /> <span style='color:#0033ff'>stated at the above of the diagram, u've posted code, but where is it? could u repost it, once again...so, it could be my reference for my assignment, i hope u'll consider my request...</span> <br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 30 Aug 2008 17:23:32 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[@izator..,<br />as u can see, arun has posted the most important part of ur assignment which is the principle of operation and hardware which is more than half of ur assignment done. i would assume that writing the code for the above hardware should be quite simple for u if u have really understood the principle explained in the previous posts of this thread.<br />I am in perfect acceptance of aruns decision to delete the code as the same assignment seems to have been given to most of the members of this forum from ur place and it would be unfair (especially to ur faculty who gave u people this assignment)  if most of ur collegues  just download the code and complete the assignment without really understanding the concept( which is why u were given the assignemnt in the first place, right?).<br /><br />So i would advice u on starting on something and then we can always suggest/comment on it.<br /><br />good luck <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 31 Aug 2008 00:49:39 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[10) the tick time of 50 msec can be reduced to say 20msec but to get 10 sec delay we would require to count 500 interrupts but the 8 bit counter can count max upto 255D<br /><br />i need 30 seconds delay which is 600D but the max is 255D<br />so how do i get 30 secs? by setting tick time higher than 50msec? Biggest is 60+msec?<br />but still cannot get a total of 30seconds.<br />pls teach me how to get 30 secs...<br /><br />Edit: Just think of an idea of making 2 loops, but the exact coding still not sure about it...]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Thu, 04 Sep 2008 15:35:04 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[well u thought of it right. but to generate a 30seconds tick (that is a very long time ), u may have to change the timer mode to 16 bits ( two bytes)  and further add a two byte counter in the overflow interrupt. 30 seconds = 30,000,000 uS. == total 4 byte counter.]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Thu, 04 Sep 2008 21:24:38 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<div class='quote_top'>Arun Kumar V wrote ...</div><div class='quote'><br />hello caze,<br /><br />as promised here's my code and schematic, i have written for 8 I/Os your task is to further increase it to 10 I/Os (its easy after you go thru the code)  -  Enjoy !<br /><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_final.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_final_.jpg' class='bbcode' alt='' width='500' height='333'  /></a><br /><br /><a class='bbcode' href='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_working.jpg' rel='external'  target='_blank'><img src='http://www.8051projects.net/e107_files/public/1215481323_426_FT10431_working_.jpg' class='bbcode' alt='' width='500' height='326'  /></a><br /><br /><br /><br />: code deleted by Arun<br /><br /><br /><br /><br />i have simulated and tested the code using Ds89C430 and it works well !<br /><br /><br />Arun<br /></div><br /><br />another noob question here, hope u all dun mind...<br />by comparing Arun's schematic n Junied's schematic (http://rapidshare.de/files/40330614/imp_scheme.pdf.html)<br />Arun's connect those buttons to P3.2(INT0) which Junied did not.<br />I know it is for interrupt purpose, but i not really clear about tis part.<br />Is it we must use interrupts to implemented tis functions? Is there any others way?<br />For example, below is a sample code i search thru the internet, it can poll between 2 inputs and countdown 10 secs but it does not uses interrupts. Is tis code correct?<br /><br />(If you pressed switch A, and your program goes into a delay loop to give you the 10 sec delay, then switch B will not be polled, and therefore has no effect while the system is waiting for this 10 sec delay to complete.<br /><br />The program below should give you some idea. It is not debugged, but the idea is there.<br /><br />The two switches have to be polled regularly. Let the timer runs freely and overflow every 50 ms. If switch A is pressed, initialise the value of R1 to 200. Decrement R1 everytime the timer overflow. After 200 overflow (200 x 50ms = 10 s), R1 becomes zero, and the program turn off LED A. LED B is separately controlled by the value in R2.<br /><br /><br />MOV TMOD,#10H ; CONFIGURE TIMER 1<br />MOV TH1,#3CH ; ASSUME 12 MHZ CRYSTAL<br />MOV TL1,#B0H ; TIMER TAKES 50MS TO OVERFLOW<br />SETB TR1 ; START TIMER 1<br /><br />POLL: ; POLL FOR THE SWITCHES<br />JNB P1.0,AA1 ; JUMP IF SWITCH A IS PRESSED<br />JNB P1.1,BB1 ; JUMP IF SWITCH B IS PRESSED<br /><br />POLL2:<br />JNB TF1,POLL ; TIMER NOT OVERFLOW YET, CONTINUE TO POLL<br />CLR TF1<br />MOV TH1,#3CH<br />MOV TL1,#B0H<br />CJNE R1,#0,CNTDOWN_A<br />SETB P3.0 ; OFF LED A<br />CJNE R2,#0,CNTDOWN_B<br />SETB P3.1 ; OFF LED B<br />SJMP POLL<br /><br />AA1:<br />MOV R1,#200D ; START TIMING<br />CLR P3.0 ; ON LED A<br />SJMP POLL2<br /><br />BB1:<br />MOV R2,#200D<br />CLR P3.1 ; ON LED B<br />SJMP POLL2<br /><br />CNTDOWN_A:<br />DEC R1<br />SJMP POLL<br /><br />CNTDOWN_B:<br />DEC R2<br />SJMP POLL<br />)<br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 05 Sep 2008 01:40:47 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<div class='quote_top'>pdi33 wrote ...</div><div class='quote'><br />well u thought of it right. but to generate a 30seconds tick (that is a very long time ), u may have to change the timer mode to 16 bits ( two bytes)  and further add a two byte counter in the overflow interrupt. 30 seconds = 30,000,000 uS. == total 4 byte counter.<br /></div><br /><br />I do not understand "and further add a two byte counter in the overflow interrupt. 30 seconds = 30,000,000 uS. == total 4 byte counter." <br />Wat u mean by overflow interrupt? add 2 byte counter?<br />By setting timer mode to 16bits(TMOD,#10H) blah blah blah i get 50mS each cycle.<br />den i MOV R1,#200 to get 10secs. I cant MOV R1,#600 to get 30secs becoz the max is 255 only.<br />Can i do like tis? Like creating delay for multiplexing?<br />LOOP1: MOV R1,#200<br />LOOP2: MOV R2,#3    ;200*3=600 =) <br />LOOP3: DJNZ R1,$<br />             DJNZ R2,LOOP2<br /><br />p/s: becoz on the other thread Arun said tis "3) once Key is detected, particular LED is Lit and timer1 is loaded for 30sec delay<br />( 50mS X 20d = 1000mS or 1 Sec, <span style='color:#ff0000'>for 30 sec increment a Register 30 times)</span> after the delay the led is switched off."]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 05 Sep 2008 02:13:34 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[5) in the timer0 ISR declare 10 counters (use registers/variables) check which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti continue till you reach 200 decimal ( 50mSec X 200 times = 10secs) once the counters reach 200 then stop the device and clear the flag/s<br /><br />how to do tis part?<br />already confuse between timer n counter, somore declare counters in timer0 ISR.<br />totally blur...]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 05 Sep 2008 05:50:54 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[Hello   Mr.shabiul,<br /><br />i feel you are trying to do too many things at the same time, pl. follow a step by step approach. <br /><br /><br />the solution i offered here is for this particular Challenge, so the connecting of Int0 pin with other input port pins works in this context and you don't have to connect it this way always in your other circuits.<br /><br />now about the timer delay.<br /><br />You have to use timer ISR ( interrupt Service Rotuine). in Data seg ( i,e RAM) define variables by some name like count_1......count_10 and also 10 flags by name like Flag_1.....Flag_10  and now read the algorithm carefully (point no.5):<br /><br /><div class='indent'>5) in the timer0 ISR declare 10 counters (use registers/variables) check which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti continue till you reach 200 decimal ( 50mSec X 200 times = 10secs) once the counters reach 200 then stop the device and clear the flag/s</div><br /><br /><br /> and now for 30 sec delay question.<br /><br />first make a delay for 1 Sec and then use this 1 sec delay as basic tick  to get multiple seconds/mins/hrs/days delay, here's a code snippet :<br /><br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;">MAIN:<br /><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">TMOD</span>,#<span style="color: #ff0000;">01H</span> &nbsp;<span style="color: #adadad; font-style: italic;">; TIMER 0 MODE 1</span><br /><span style="color: #00007f; font-weight:bold;">MOV</span> &nbsp;<span style="color: #46aa03; font-weight:bold;">TL0</span>,#<span style="color: #ff0000;"><span style="color: #ff0000;">0B</span>0H</span>&nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;Lower Byte &nbsp; ; 50 mS DELAY VALUES ( 12 Mhz XTAL)</span><br /><span style="color: #00007f; font-weight:bold;">MOV</span> &nbsp;<span style="color: #46aa03; font-weight:bold;">TH0</span>,#<span style="color: #ff0000;">03CH</span>&nbsp; <span style="color: #adadad; font-style: italic;">;Upper Byte</span><br /><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R1</span>,#20D &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; COUNTER FOR 1 SEC</span><br /><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R2</span>,#30D &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; COUNTER FOR 30 SECS</span><br /><span style="color: #00007f; font-weight:bold;">SET</span> &nbsp; TR0&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;Run timer</span><br /><br /><span style="color: #00007f; font-weight:bold;">CLR</span> LED &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; LED IS ON</span><br /><span style="color: #00007f; font-weight:bold;">SJMP</span> $<br /><br /><br /><span style="color: #adadad; font-style: italic;">;TIMER0 ISR</span><br /><br /><span style="color: #00007f; font-weight:bold;">CLR</span> TR0<br /><span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R1</span>,<span style="color: #0000ff;">CONTINUE</span><br /><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R1</span>,#20D &nbsp; <span style="color: #adadad; font-style: italic;">; RELOAD COUNTERS FOR NEXT CYCLE</span><br /><span style="color: #00007f; font-weight:bold;">DJNZ</span> <span style="color: #46aa03; font-weight:bold;">R2</span>,<span style="color: #0000ff;">CONTINUE</span><br /><span style="color: #00007f; font-weight:bold;">SETB</span> &nbsp;LED &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; AFTER COMPLETION OF &nbsp;30 SEC DELAY OFF THE LED</span><br /><span style="color: #00007f; font-weight:bold;">MOV</span> <span style="color: #46aa03; font-weight:bold;">R2</span>,#30D &nbsp; <span style="color: #adadad; font-style: italic;">; RELOAD COUNTERS FOR NEXT CYCLE</span><br />&nbsp;<br /><span style="color: #0000ff;">CONTINUE</span>:<br /><span style="color: #00007f; font-weight:bold;">MOV</span> &nbsp;<span style="color: #46aa03; font-weight:bold;">TL0</span>,#<span style="color: #ff0000;"><span style="color: #ff0000;">0B</span>0H</span>&nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;Lower Byte &nbsp; ; 50 mS DELAY VALUES ( 12 Mhz XTAL)</span><br /><span style="color: #00007f; font-weight:bold;">MOV</span> &nbsp;<span style="color: #46aa03; font-weight:bold;">TH0</span>,#<span style="color: #ff0000;">03CH</span>&nbsp; <span style="color: #adadad; font-style: italic;">;Upper Byte</span><br /><span style="color: #00007f; font-weight:bold;">SETB</span> TR0<br /><br /><span style="color: #00007f; font-weight:bold;">RETI</span></div></div><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 05 Sep 2008 11:55:26 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<div class='quote_top'>Arun Kumar V wrote ...</div><div class='quote'><br />Hello   Mr.shabiul,<br /><br />i feel you are trying to do too many things at the same time, pl. follow a step by step approach. <br /><br />the solution i offered here is for this particular Challenge, so the connecting of Int0 pin with other input port pins works in this context and you don't have to connect it this way always in your other circuits.<br /><br />now about the timer delay.<br /><br /> you have to use timer ISR ( interrupt Service Rotuine). in Data seg ( i,e RAM) define variables by some name like count_1......count_10 and also 10 flags by name like Flag_1.....Flag_10  and now read the algorithm carefully (point no.5):<br /><br /><div class='indent'><span style='color:#ff0000'>5) in the timer0 ISR declare 10 counters (use registers/variables) check</span> which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti continue till you reach 200 decimal ( 50mSec X 200 times = 10secs) once the counters reach 200 then stop the device and clear the flag/s</div><br /><br /><br /><br /><br />Arun<br /></div><br /><br />it is because my project also require 4 inputs which your solution offer 10 inputs, i guess it is the same thing right? So do I need to connect those 4 inputs to INT0?<br /><br />by the way, i had read ur algorithm very carefully,but i m still not quite clear about it.(well, i m just a new learner to assembly coding)<br />5) in the timer0 ISR declare 10 counters (use registers/variables) check[/color] which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti <br />May you explain tis part further?<br />Hope to hear from u soon<br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 05 Sep 2008 12:23:30 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[How to define others variables rather than R0-R7 in register banks 0<br />and without using register banks 1<br />becoz changing register banks looks complicated...<br />and my R0-R7 in register banks 0 is fully occupied...<br /><br />For example<br />FLAG1: DS 1<br />den in main program <br />MOV FLAG1,#01H <br /><br />tis giv segment type mismatch in my compliler<br /><br />wat is the problem?]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 06 Sep 2008 10:35:27 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<br />  Shabiul, may be you are forgetting the 256 bytes RAM on board 8052, declare Variables in RAM and In Assembly this is how it can be done:<br /><br /> DSEG    ORG 0020H<br />COUNTER_1: DS 1<br />COUNTER_2: DS 1<br /><br />and for FLAGS<br /><br />FLAG_1 BIT 1<br />FLAG_2 BIT 1<br />...................................<br /><br /><br /><br />Arun<br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 06 Sep 2008 10:43:30 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[why is FLAG_1 BIT 1 while COUNTER_1: DS 1?<br /><br />by the way, there is alot questions in the previous posts tat you din answer me...<br /><br />regarding checking the flag, THE FLAG is just normal variable or interrupt FLAG?]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 06 Sep 2008 10:51:40 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[shabiul, you have  edited your previous post after my reply ( see the time stamp, i replied at 11.15 pm and you modified your last reply after reading my answer at 11.21pm)<br /><br />don't repeat this sought of thing.<br /><br />now about your problem, bit and DS, before i clear your doubt can you tell me the difference between Port1 and Port pin 1.0<br /><br /><br />i can proceed only when you answer my above question <br /><br /><br />Arun]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 06 Sep 2008 11:20:51 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[i edit my post just because i got new question and i dun wan to double post.<br />about ur question, Port1 means the whole port1.0-1.7, port pin 1.0 means only the pin.<br />correct me if wrong.<br /><br />by the way i mean u did not answer my previous 2-3 posts but not the last post.]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 06 Sep 2008 11:37:32 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[<div class='indent'>about ur question, Port1 means the whole port1.0-1.7, port pin 1.0 means only the pin.correct me if wrong.</div><br /><br />other way of putting it would be, port1.0 is a <strong class='bbcode bold'>bit</strong> of port1 and port1 is a <strong class='bbcode bold'>8bit</strong> port. <br /><br />so port1 (or any 8 bit port ) can be called as a <strong class='bbcode bold'>register</strong> which is both Bit &amp; byte addressable (i,e you can write or read a single port bit or full 8 bit register).<br /><br /><br /><div class='indent'>why is FLAG_1 BIT 1 while COUNTER_1: DS 1?</div><br /><br />when you declare  a variable in RAM area, you have to specify to compiler the size of that variable,<br /><br />for eg:<br /><br />COUNTER_1: <strong class='bbcode bold'>DS 1</strong>   ; means the variable counter_1 is one byte wide ( like a  8 bit register)<br /><br />and  now declaring a flag,<br /><br />FLAG_1 <strong class='bbcode bold'>BIT </strong>1   ;   flag_1 is a single bit  and not whole 8 bit Register.<br /><br /><br />now data moves with byte wide Variable and bit flag:<br /><br />to write/read a 8 bit variable:<br /><br />MOV COUNTER_1,#0FFH   ;  move value 255d to counter_1<br />MOV A,COUNTER_1            ; read value of Counter_1 to Accu<br /><br /><div class='indent'>FLAG1: DS 1<br />den in main program<br />MOV FLAG1,#01H<br /><br />tis giv segment type mismatch in my compliler<br /><br />wat is the problem? <br /><br /></div><br /><br />now with Bit :<br /><br />how would you turn On or Turn Off a port bit ?<br /><br />SETB P1.1<br />CLR P1.1<br /><br />same way you can Set or clear a bit Flag:<br /><br />SETB FLAG_1<br />CLR FLAG_1<br /><br />but cannot use byte instructions with single bit variable/flag<br /><br />MOV FLAG_1,#0FFH   ; is wrong and gives Error <br /><br />it is like writing :<br /><br />MOV P1.1,#0FFH    ; which is like writing 8 bit value to a single port pin (bit), this is called <br />" illegal syntax " by the compiler/assembler<br /><br /><br />Flag/s are used to indicate only two states  i,e  1 or 0  ( a light is ON or OFF)<br />Variable is used to store data/value which often changes or varies  ( Seconds Variable of a Clock)<br /> <br /><br />Arun<br /><br /><br /><br /><br /><br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 06 Sep 2008 19:37:41 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[@ Mr.shabiul,<br /><br />I Bet even your College Professor wouldn't have explained the whole concept with such clarity as Arun did.<br /><br />so the least you can do is " Thank "  Arun and other moderators who are taking pain in explaining the concepts from root level.<br /><br />the college professors are "paid "to solve your problems but they do not do that ( if they did, you wouldn't be asking for help in forums)<br /><br />on the other hand Moderators here are doing Free social service by sharing their knowledge. <br /><br />i should say you folks (your fellow country men) are Lucky to be members of this forum, because other forums Like popular 8052.com would not entertain assignments and home works ( they straight away lock/delete your posts) so thank God and thank the Mods by pressing the "Thanks button" <br /><br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 06 Sep 2008 20:39:16 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[Ya, i know moderators here are very nice and willing to help, tats why i stick to here.<br />I keep refresh the page to see if they had replied me or not, becoz i m desperate &amp; my project is running out of time. Maybe i had ask too much question and i did not speak in proper manner, but i really appreciate their help.<br /> <div class='indent'>the college professors are "paid "to solve your problems but they do not do that ( if they did, you wouldn't be asking for help in forums)</div> <br />maybe they did,maybe they did not,its not for me to comment about it. <br />Well maybe the problem is with myself... i m just not good in programming.<br />and the text book has too little example to refer]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 07 Sep 2008 04:18:48 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
						<item>
						<title>Re: IO PORT PROGRAMING CHALANGE</title>
<link>http://www.8051projects.net/forum-t10431.html</link>
<description><![CDATA[@Arun<br /><br />thanks, u explained very well n clear. I wonder why i just dun understand such a simple thing be4....<br />anyway,I m still stuck in tis part 5) n 6)<br /><span style='color:#ff0000'>5) in the timer0 ISR declare 10 counters (use registers/variables) check which flag/s is high( already set high in the Ex int.ISR), if a match is found increment that particular counter/s and reti continue till you reach 200 decimal ( 50mSec X 200 times = 10secs) once the counters reach 200 then stop the device and clear the flag/s<br />6) even when some devices are running and some other new device/s is triggered the counter for that particular new device is also incremented along with the old running one</span><br />How to fullfill part6 conditions? just by doing the code in part5 will do?<br />can i do like tis for part 5?below is sample timer ISR for 2 switches &amp; flag1 flag2 already SETB in external INT.<br />T1_ISR:<br />	PUSH ACC<br />	PUSH PSW<br />	MOV A,FLAG1<br />	CJNE A,#01H,COUNTER1<br />	CLR TR1<br />	DJNZ R5,CONTINUE<br />	MOV R5,#20D   	<br />	DJNZ R6,CONTINUE<br />	SETB  LED1      <br />	MOV R6,#30D   	<br /> <br />	CLR FLAG1	;<br />	<br />COUNTER1:<br />	MOV A,FLAG2<br />	CJNE A,#01H,RETURN<br />	CLR TR1<br />	DJNZ R5,CONTINUE<br />	MOV R5,#20D   	 <br />	DJNZ R6,CONTINUE<br />	SETB  LED2       <br />	MOV R6,#30D   	 <br /> <br />	CLR FLAG2<br /><br />RETURN:<br />       POP PSW<br />       POP ACC<br /><br />CONTINUE:<br />        MOV  TL1,#0B0H  ;Lower Byte   ; 50 mS DELAY VALUES ( 12 Mhz XTAL)<br />	MOV  TH1,#03CH  ;Upper Byte<br />	SETB TR1<br /><br />	RETI<br /><br />INT0_ISR:<br />.<br />.<br />.<br />RETI<br /><br />	<br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 07 Sep 2008 04:29:53 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10431.html</guid>
</item>
				</channel>
				</rss>