Revision: 1456
Author: [email protected]
Date: Mon Nov 2 20:36:28 2009
Log: fixed getting started table & blink tutorial
http://code.google.com/p/jallib/source/detail?r=1456
Modified:
/trunk/doc/dita/tutorials/tutorial_blink_a_led.xml
/trunk/doc/dita/tutorials/tutorial_getting_started.xml
=======================================
--- /trunk/doc/dita/tutorials/tutorial_blink_a_led.xml Sat Oct 31 13:55:40
2009
+++ /trunk/doc/dita/tutorials/tutorial_blink_a_led.xml Mon Nov 2 20:36:28
2009
@@ -52,7 +52,7 @@
</section>
<section>
<title>Let’s write some code</title>
- <p>So now we’re going to write the code that will make our LED
blink. All code will be shown in green text. You can read more about JAL
language useage here: <xref
href="http://www.casadeyork.com/jalv2/language.html" class="- topic/xref "
format="html">http://www.casadeyork.com/jalv2/language.html</xref></p>
+ <p>So now we’re going to write the code that will make our LED
blink. All code will be in highlighted text. You can read more about JAL
language useage here: <xref
href="http://www.casadeyork.com/jalv2/language.html" format="html" class="-
topic/xref ">http://www.casadeyork.com/jalv2/language.html</xref></p>
</section>
<section>
<title>Title & Author Block</title>
@@ -104,12 +104,13 @@
</section>
<section>
<title>Choose an output pin</title>
- <p>Let’s choose an output pin to control our LED. As you can see
from the circuit, our LED is connected to pin #2. Let’s check our datasheet
to find the pin name from the pinout diagram.</p>
+ <p>Let’s choose an output pin to control our LED. As you can see
from the circuit, our LED is connected to pin #2. Let’s check our datasheet
to find the pin name from the pinout diagram. </p>
+ <p>The PDF datasheet for this PIC and for all others can be
downloaded from the microchip website. Here is the datasheet for this PIC
<xref href="http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf"
format="html">http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf</xref>
,
and here is the pinout diagram from the datasheet:</p>
<p><image href="images/blink_a_led_16f877_pinout.jpg"/></p>
<p>As you can see, we are using the pin RA0/ANO at pin #2. RA0 is
the pin name we are looking for. AN0 is another name for this same pin
(used in the analog to digital tutorial), but we can ignore it in this
tutorial. In the JAL language RA0 is written as pin_A0</p>
- <p>Now let’s read the details of this pin in the PDF file on page
10. As you can see RA0 is a TTL Digital I/O pin. We are checking this to
make sure it is not a open drain output. Open drain outputs (like pin RA4)
require a pull-up resistor from the pin to V+</p>
+ <p>Now let’s read the details of this pin in the datasheet on page
10. As you can see RA0 is a TTL Digital I/O pin. We are checking this to
make sure it is not a open drain output. Open drain outputs (like pin RA4)
require a pull-up resistor from the pin to V+</p>
<p><image href="images/blink_a_led_16f877_pin_info.jpg" width="500"
otherprops="clickable"/></p>
- <p>Now write code for pin A0. We are writing an “alias” only because
in the future we can refer to pin 2 (A0) as “led”. This way we no longer
need to remember the name of the pin (exept for the next line of code we
will write)</p>
+ <p>Now write code for pin A0. We are writing an “alias” only because
in the future we can refer to pin 2 (A0) as “led”. This way we no longer
need to remember the name of the pin (exept for the directional register in
the next line of code we will write).</p>
<p><codeblock>--
-- You may want to change the selected pin:
alias led is pin_A0</codeblock></p>
@@ -118,21 +119,22 @@
<title>Configure the pin as an inout or output</title>
<p>Now we must tell the PIC if this is an input or an output pin.
The directional setting is always named (pin_ + pinname_ + direction).
Since we are writing data to the port, to turn the LED on, it is an
output.</p>
<p><codeblock>pin_A0_direction = output</codeblock></p>
- <p>A better way to write this, is to make an alias with “alias
led_direction is pin_A0_direction”, then write “led_direction = output”,
then we can change it from output to input in the middle of the program
without knowing the pin name.</p>
+ <p>We could make an alias for this as well: “alias led_direction is
pin_A0_direction”, then write “led_direction = output”. This way, we can
change it from output to input in the middle of the program without knowing
the pin name. But in this case, we will only use pin_A0_direction once in
our program so there is no need to make an alias.</p>
</section>
<section>
<title>Write your program</title>
<p>So, now that we have the LED under our control, let’s tell it
what to do.</p>
<p>We will want our led to continue doing whatever we want it to do
forever, so we’ll make a loop</p>
<p><codeblock>forever loop</codeblock></p>
- <p>In this loop, we will tell the LED to turn on (put 2 spaces
before each line within the loop)</p>
- <p><codeblock> led = ON</codeblock></p>
+ <p>It is good practice to indent before each line within the loop
for readability. 3 spaces before each line is the standard for JALLib.</p>
+ <p>In this loop, we will tell the LED to turn on.</p>
+ <p><codeblock> led = ON</codeblock></p>
<p>now have some delay (250ms) a quarter of a second so we can see
the led on.</p>
- <p><codeblock> _usec_delay(250000)</codeblock></p>
+ <p><codeblock> _usec_delay(250000)</codeblock></p>
<p>turn the LED off again</p>
- <p><codeblock> led = OFF</codeblock></p>
+ <p><codeblock> led = OFF</codeblock></p>
<p>and have another delay before turning it back on again</p>
- <p><codeblock> _usec_delay(250000)</codeblock></p>
+ <p><codeblock> _usec_delay(250000)</codeblock></p>
<p>close our loop, when the PIC gets to this location, it will go
back to the beginning of the loop</p>
<p><codeblock>end loop
--</codeblock></p>
@@ -196,6 +198,9 @@
<section>
<title>Write the hex file to your PIC</title>
<p>Take your PIC out of your circuit and put it in your programmer.
With your programming software, open the blink_a_led.hex file. You should
see that hex data loaded in your software. Now click the Write button. Your
software will tell you when it is done.</p>
+ </section>
+ <section>
+ <title>Let's Try It</title>
<p>Put your PIC back into your circuit, double check your circuit if
you haven’t already, and make sure your PIC is facing the correct
direction. Apply power to your circuit.</p>
<p>It’s alive! You should see your led blinking! Congradulations on
your first JALv2 + JALLIB circuit!</p>
</section>
=======================================
--- /trunk/doc/dita/tutorials/tutorial_getting_started.xml Mon Nov 2
00:55:26 2009
+++ /trunk/doc/dita/tutorials/tutorial_getting_started.xml Mon Nov 2
20:36:28 2009
@@ -67,7 +67,6 @@
<row>
<entry>16F877</entry>
<entry>$5.92</entry>
- <entry/>
</row>
<row>
<entry>16F877A</entry>
@@ -122,7 +121,7 @@
<image href="images/getting_started_micropro.jpg"/>
</section>
<section>
- <p>Ok, enough of this boring stuff, lets build something!</p>
+ <p>Ok, enough of this boring stuff, lets build something! Start with
the <xref href="tutorial_blink_a_led.xml">Blink A Led Tutorial</xref>.</p>
</section>
</body>
</topic>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---