Revision: 1517
Author: [email protected]
Date: Thu Dec  3 23:15:31 2009
Log: renamed installation.xml to tutorial_installation.xml. fixed alias in  
hard disk tutorial, added notes to sd card tutorial.
http://code.google.com/p/jallib/source/detail?r=1517

Added:
  /trunk/doc/dita/tutorials/tutorial_installation.xml
Deleted:
  /trunk/doc/dita/tutorials/installation.xml
Modified:
  /trunk/doc/dita/tutorials/tutorial_pata_hard_disk.xml
  /trunk/doc/dita/tutorials/tutorial_sd_card.xml
  /trunk/doc/dita/tutorials/tutorials.ditamap

=======================================
--- /dev/null
+++ /trunk/doc/dita/tutorials/tutorial_installation.xml Thu Dec  3 23:15:31  
2009
@@ -0,0 +1,37 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- This document was created with Syntext Serna Free. --><!DOCTYPE topic  
PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd" []>
+<topic id="template_id">
+  <title>Installation</title>
+  <prolog>
+    <author>Jallib Group</author>
+    <publisher>Jallib Group</publisher>
+  </prolog>
+  <body>
+    <p id="firstcontent">JALv2 &amp; Jallib installation guide</p>
+    <section>
+      <title>Windows Install:</title>
+      <ol>
+        <li>Download jalpack (installer executable) from <xref  
href="http://jaledit.googlecode.com/files/JALPack_2.4_0.4_0.6.1.0.exe";  
format="html">http://jaledit.googlecode.com/files/JALPack_2.4_0.4_0.6.1.0.exe</xref></li>
+        <li>Run the setup file</li>
+        <li>Run JalEdit.exe from the jaledit directory</li>
+        <li>(optional) Click Tools Menu -&gt; Environment Options -&gt;  
Programmer, Then Set the Programmer Executable Path</li>
+      </ol>
+      <p>You should get something like this on windows:</p>
+      <p/>
+      <image href="images/installation_jalv2_dir.jpg"/>
+      <p/>
+    </section>
+    <section>
+      <title>Linux Install</title>
+      <ol>
+        <li>Go to <xref  
href="http://code.google.com/p/jallib/downloads/list";  
format="html">http://code.google.com/p/jallib/downloads/list</xref>, get  
the link location of the jallib-pack (.tar.gz file)</li>
+        <li>Go to the directory you wish to install JALv2</li>
+        <li>Download the package with: <cmdname>$ wget [link location of  
the jallib-pack]</cmdname> or simply use your favorite browser to download  
archive in the appropriate directory.</li>
+        <li>unzip the package with: <cmdname>$ tar xzf  
[filename.tar.gz]</cmdname></li>
+      </ol>
+      <note>Jaledit runs under Wine on Linux</note>
+      <p>You should get something like this on linux:</p>
+      <image href="images/installation_jalv2_dir_linux.jpg"/>
+    </section>
+  </body>
+</topic>
=======================================
--- /trunk/doc/dita/tutorials/installation.xml  Sun Nov 22 01:35:00 2009
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- This document was created with Syntext Serna Free. --><!DOCTYPE topic  
PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd" []>
-<topic id="template_id">
-  <title>Installation</title>
-  <prolog>
-    <author>Jallib Group</author>
-    <publisher>Jallib Group</publisher>
-  </prolog>
-  <body>
-    <p id="firstcontent">JALv2 &amp; Jallib installation guide</p>
-    <section>
-      <title>Windows Install:</title>
-      <ol>
-        <li>Download jalpack (installer executable) from <xref  
href="http://jaledit.googlecode.com/files/JALPack_2.4_0.4_0.6.1.0.exe";  
format="html">http://jaledit.googlecode.com/files/JALPack_2.4_0.4_0.6.1.0.exe</xref></li>
-        <li>Run the setup file</li>
-        <li>Run JalEdit.exe from the jaledit directory</li>
-        <li>(optional) Click Tools Menu -&gt; Environment Options -&gt;  
Programmer, Then Set the Programmer Executable Path</li>
-      </ol>
-      <p>You should get something like this on windows:</p>
-      <p/>
-      <image href="images/installation_jalv2_dir.jpg"/>
-      <p/>
-    </section>
-    <section>
-      <title>Linux Install</title>
-      <ol>
-        <li>Go to <xref  
href="http://code.google.com/p/jallib/downloads/list";  
format="html">http://code.google.com/p/jallib/downloads/list</xref>, get  
the link location of the jallib-pack (.tar.gz file)</li>
-        <li>Go to the directory you wish to install JALv2</li>
-        <li>Download the package with: <cmdname>$ wget [link location of  
the jallib-pack]</cmdname> or simply use your favorite browser to download  
archive in the appropriate directory.</li>
-        <li>unzip the package with: <cmdname>$ tar xzf  
[filename.tar.gz]</cmdname></li>
-      </ol>
-      <note>Jaledit runs under Wine on Linux</note>
-      <p>You should get something like this on linux:</p>
-      <image href="images/installation_jalv2_dir_linux.jpg"/>
-    </section>
-  </body>
-</topic>
=======================================
--- /trunk/doc/dita/tutorials/tutorial_pata_hard_disk.xml       Fri Nov 27  
21:27:18 2009
+++ /trunk/doc/dita/tutorials/tutorial_pata_hard_disk.xml       Thu Dec  3  
23:15:31 2009
@@ -23,16 +23,24 @@
        <p>Before you start, make sure you use a drive you do not care  
about. We are not responsible for your drive of the data that is on it.</p>
        <p>You can find more general info at <xref  
href="http://en.wikipedia.org/wiki/Parallel_ATA";  
format="html">http://en.wikipedia.org/wiki/Parallel_ATA</xref>, and you can  
find more detailed technical info at <xref  
href="http://www.gaby.de/gide/IDE-TCJ.txt";  
format="html">http://www.gaby.de/gide/IDE-TCJ.txt</xref></p>
        <image href="images/pata_hard_disk_pile.jpg" width="450"/>
+    </section>
+    <section>
        <title>Drive Types - PATA vs SATA</title>
        <p>There are two types of hard disks PATA (parallel ata) and SATA  
(serial ata). In this tutorial we will use PATA, these drives use a 40 pin  
IDE connector. The newer type of drive SATA has only 7 pins but there is no  
Jallib library for these drives at the moment. Both types of hard disks   
are available with massive amounts of data space.</p>
+    </section>
+    <section>
        <title>Drive Data Size</title>
        <p>The current jallib library will accept drives up to 128GB. The  
128GB limit is due to and addressing limitation, this is the 28 bit  
addressing limitation.The max address you will be able to reach is hex  
0xFFFFFFF. If you multiply this address by 512 bytes (1 sector) you get a  
max size of 137,438,952,960 bytes, yes this does equal 128GB. Eventually I  
may upgrade the library for 48bit addressing which will allow up to a max  
drive size hex 0xFFFFFFFFFFFF * 512 = 128P Petabytes. But now that I think  
about it, 128 GB should be enough!</p>
+    </section>
+    <section>
        <title>Actual Size</title>
        <p>The most common drive sizes today are 3.5&quot; and 2.5&quot;.  
The 3.5 inch drives are commonly used in desktop computers, 2.5&quot;  
drives are used in laptops. The 2.5&quot; drives are nice for your circuit  
because they do not require a 12v supply voltage, and they use much less  
power.</p>
        <image href="images/pata_hard_disk_drive_size.jpg" width="450"/>
        <p>If you wish to use a 2.5&quot; laptop hard drive, you may need a  
2.5&quot; to 3.5&quot; IDE adapter like this one:</p>
        <image href="images/pata_hard_disk_adapter.jpg" width="200"  
otherprops="clickable"/>
        <image href="images/pata_hard_disk_adapter2.jpg" width="200"/>
+    </section>
+    <section>
        <title>Build a breadboard connector</title>
        <p>Now, if your going to put one of these into your circuit,  
you&apos;ll need to plug the drive into your breadboard. I took a 40pin IDE  
connector off an old motherboard. The easiest way to get large components  
of a board is to use a heat gun on the bottom side of the board to melt the  
solder on all pins at once. </p>
        <p>Now take this connector and stick it into some blank breadboard  
and add some pins. The blank breadboard I cut is 4 holes wide by 20 long.  
Put the connector in the middle and connect the pins on the outside, join  
each pin with each pin of the connector. </p>
@@ -40,8 +48,12 @@
        <image href="images/pata_hard_disk_connector_top.jpg" width="200"  
otherprops="clickable"/>
        <image href="images/pata_hard_disk_connector_bottom.jpg" width="200"  
otherprops="clickable"/>
        <image href="images/pata_hard_disk_connector_side.jpg" width="200"  
otherprops="clickable"/>
+    </section>
+    <section>
        <title>Circuit Power</title>
        <p>It is very important that you have enough power to drive your  
circuit. Hard drives need a lot of amps to run, especially the 3.5&quot;  
drives, so make sure you have a decent 5v and 12v power supply. I suggest  
that you DO NOT use your PC&apos;s power supply to drive your circuit. You  
can easily short circuit your power supply and blow up your PC. If you  
really insist on doing this, you better put a fuse on both 5v and 12v  
between your PC and your circuit. Just remember that I told you not to!</p>
+    </section>
+    <section>
        <title>IDE Connector Pin-out</title>
        <p>Pin 1 on the IDE cable is the red stripe. Here the pin out for  
the male connector I took off a motherboard:</p>
        <image href="images/pata_hard_disk_pins.jpg"/>
@@ -187,6 +199,8 @@
        <p>Here&apos;s what the completed circuit should look like  
(don&apos;t turn on the power yet):</p>
        <image href="images/pata_hard_disk_small_drive.jpg" width="500"  
otherprops="clickable"/>
        <image href="images/pata_hard_disk_large_drive.jpg" width="500"  
otherprops="clickable"/>
+    </section>
+    <section>
        <title>Compile and write the software to your PIC</title>
        <p>The hard disk lib (pata_hard_disk.jal) and a sample file  
(16f877_pata_hard_disk.jal) will be needed for this project. You will find  
these files in the lib &amp; sample directories of your jallib  
installation. </p>
        <p>The most up to date version of the sample &amp; library can be  
found at:</p>
@@ -194,6 +208,8 @@
        <p>Library file - <xref  
href="http://jallib.googlecode.com/svn/trunk/include/external/storage/harddisk/pata_hard_disk.jal";
  
format="html">http://jallib.googlecode.com/svn/trunk/include/external/storage/harddisk/pata_hard_disk.jal</xref></p>
        <p>Now lets test it and make sure it works. Compile and program your  
pic with 16f877_sd_card.jal from your jallib samples directory. If you are  
using another pic, change the &quot;include 16f877&quot; line in  
16f877_sd_card.jal to specify your PIC before compiling. </p>
        <p>Now that you have compiled it, burn the .hex file to your PIC  
with your programmer</p>
+    </section>
+    <section>
        <title>Power It Up</title>
        <p>Plug your circuit into your PC for serial port communication at  
38400 baud rate. Now turn it on.  It should do the following in this  
order:</p>
        <ol>
@@ -205,8 +221,6 @@
          <li>The led will turn on and off a few times and send some data to  
your PC&apos;s serial port.</li>
          <li>The PIC now &quot;spin down&quot; the drive at the end of the  
program.</li>
        </ol>
-    </section>
-    <section>
        <b>ASCII output</b>
        <p><image href="images/pata_hard_disk_ascii.jpg" width="450"  
otherprops="clickable"/></p>
        <p><b>Hex output</b></p>
@@ -215,6 +229,8 @@
  ableError loading operating system...&quot;
  </p>
        <p>In the second image (after clearing the output and resetting the  
circuit), there was too much data to show it all again. It only shows the  
last bytes received. If you get the same hex output &quot;CC DD&quot;  
followed by many &quot;FF&quot;, your circuit has successfully written data  
and read it back again. You now have a working hard disk circuit!</p>
+    </section>
+    <section>
        <title>Understand and modify the code</title>
        <p>I will go over some of the key points you need to know about hard  
disk coding. Open the sample file with an editor if you  have not done so  
already. The code in the sample file may change, therefore it may be  
different then what you see here. The sample file you have downloaded will  
always be tested and correct.</p>
        <p><b>Include the chip</b></p>
@@ -256,26 +272,26 @@
        <p>Yes, pata hard disks have a lot of pins. You will need two full  
8pin port&apos;s (port B and port D of 16F877) for data transfer, three  
register select pins, one read pulse pin and one write pulse pin. A total  
of 19 io pins. I am able to  commented out cs1/cs0 and save pins because of  
the constant we set.</p>
        <codeblock>-- pin assignments
  var volatile byte    pata_hd_data_low              is portb   -- data port  
(low bits)
-var volatile byte    pata_hd_data_low_direction    is portb_direction
-var volatile byte    pata_hd_data_high             is portd   -- data port  
(high bits)
-var volatile byte    pata_hd_data_high_direction   is portd_direction
-
-var volatile bit     pata_hd_a0                    is pin_a0
-var volatile bit     pata_hd_a0_direction          is pin_a0_direction
-var volatile bit     pata_hd_a1                    is pin_a1
-var volatile bit     pata_hd_a1_direction          is pin_a1_direction
-var volatile bit     pata_hd_a2                    is pin_a2
-var volatile bit     pata_hd_a2_direction          is pin_a2_direction
-
-var volatile bit     pata_hd_iowr                  is pin_c2
-var volatile bit     pata_hd_iowr_direction        is pin_c2_direction
-var volatile bit     pata_hd_iord                  is pin_c1
-var volatile bit     pata_hd_iord_direction        is pin_c1_direction
-
-;var volatile bit     pata_hd_cs1                   is pin_a3
-;var volatile bit     pata_hd_cs1_direction         is pin_a3_direction
-;var volatile bit     pata_hd_cs0                   is pin_a4
-;var volatile bit     pata_hd_cs0_direction         is pin_a4_direction
+alias    pata_hd_data_low_direction    is portb_direction
+alias    pata_hd_data_high             is portd   -- data port (high bits)
+alias    pata_hd_data_high_direction   is portd_direction
+
+alias     pata_hd_a0                    is pin_a0
+alias     pata_hd_a0_direction          is pin_a0_direction
+alias     pata_hd_a1                    is pin_a1
+alias     pata_hd_a1_direction          is pin_a1_direction
+alias     pata_hd_a2                    is pin_a2
+alias     pata_hd_a2_direction          is pin_a2_direction
+
+alias     pata_hd_iowr                  is pin_c2
+alias     pata_hd_iowr_direction        is pin_c2_direction
+alias     pata_hd_iord                  is pin_c1
+alias     pata_hd_iord_direction        is pin_c1_direction
+
+alias     pata_hd_cs1                   is pin_a3
+alias     pata_hd_cs1_direction         is pin_a3_direction
+alias     pata_hd_cs0                   is pin_a4
+alias     pata_hd_cs0_direction         is pin_a4_direction

  pata_hd_a0_direction = output    -- register select pin
  pata_hd_a1_direction = output    -- register select pin
@@ -313,10 +329,10 @@
        <p><b>Spin Up/Spin Down test</b></p>
        <p>It is important to know if we have some basic communication to  
the drive. We will try to spin up (turn on the drive&apos;s motor) and spin  
down (turn off the drive&apos;s motor). This will simply send the  
&quot;spin up&quot; command to the command register then &quot;spin  
down&quot;, then it will do the same once more. This shows that we have   
communication from your PIC to the hard drive.</p>
        <codeblock>for 2 loop
-    pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_SPIN_UP)   -- turn  
on motor
-    _USEC_DELAY (5_000_000) -- 5 sec delay
-    pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_SPIN_DOWN) -- turn  
off motor
-    _USEC_DELAY (5_000_000) -- 5 sec delay
+   pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_SPIN_UP)   -- turn  
on motor
+   _USEC_DELAY (5_000_000) -- 5 sec delay
+   pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_SPIN_DOWN) -- turn  
off motor
+   _USEC_DELAY (5_000_000) -- 5 sec delay
  END LOOP

  pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_SPIN_UP)       -- turn  
on motor</codeblock>
@@ -331,8 +347,8 @@
        <p>You can also use the pata_hd_read_pulse(number) procedure to skip  
past data. For every 1 value added, there will be 2 bytes skipped since  
this procedure simply reads data and ignores the input.</p>
        <codeblock>-- Read one sector
  for 256 loop                            -- 256 words, 512 bytes per sector
-  pata_hd_read_data (in_b, in_a)        -- read data
-  send_word (in_b, in_a)                -- send data via serial port
+   pata_hd_read_data (in_b, in_a)        -- read data
+   send_word (in_b, in_a)                -- send data via serial port
  end loop

  -- You will see hard disk LED on during this delay
@@ -341,8 +357,8 @@

  -- Read 2nd sector.
  for 256 loop                            -- 256 words, 512 bytes per sector
-  pata_hd_read_data (in_b, in_a)        -- read data
-  send_word     (in_b, in_a)            -- send data via serial port
+   pata_hd_read_data (in_b, in_a)        -- read data
+   send_word     (in_b, in_a)            -- send data via serial port
  end loop

  pata_hd_stop_read()       -- tell drive you are done reading
@@ -363,8 +379,8 @@
        <p>The drive is now has data for us, so let&apos;s read it. Notice  
that the input data bytes (in_b &amp; in_a) are backwards for identify  
drive (don&apos;t ask me why).</p>
        <codeblock>-- Read 512 bytes
  for 256 loop                            -- 256 words, 512 bytes per sector
-  pata_hd_read_data (in_b, in_a)        -- read data
-  send_word     (in_a, in_b )           -- send data via serial port
+   pata_hd_read_data (in_b, in_a)        -- read data
+   send_word     (in_a, in_b )           -- send data via serial port
  end loop                                -- drive info high/low bytes are  
in reverse order</codeblock>
        <p>Wait 10 seconds before the next example</p>
        <codeblock>_USEC_DELAY (10_000_000) -- wait 10 seconds before next  
example</codeblock>
@@ -380,7 +396,7 @@

  -- now write 1 sector + most of 2nd sector, data will not be written  
unless 512 bytes are sent
  for 256 + 250 loop
-  pata_hd_write_data(0xCC, 0xDD) -- write data 0xCC, 0xDD over and over
+   pata_hd_write_data(0xCC, 0xDD) -- write data 0xCC, 0xDD over and over
  end loop
  -- first sector has been written to the disk since 512 bytes where sent,
  -- but 2nd sector is not finnished, only 500 bytes sent,
@@ -392,14 +408,14 @@
        <codeblock>-- Now read the 1st sector you just wrote, should get  
0xCC, 0xDD over and over
  pata_hd_start_read(200)                 -- get drive ready for reading
  for 256 + 250 loop                      -- read 512 bytes + 500 bytes
-  pata_hd_read_data (in_b, in_a)        -- read data
-  send_word     (in_b, in_a)            -- send data via serial port
+   pata_hd_read_data (in_b, in_a)        -- read data
+   send_word     (in_b, in_a)            -- send data via serial port
  end loop

  -- if you want, you can read back the last 6 bytes that are 0xFF
  for 6 loop
-  pata_hd_read_data (in_b, in_a)        -- read data
-  send_word     (in_b, in_a)            -- send data via serial port
+   pata_hd_read_data (in_b, in_a)        -- read data
+   send_word     (in_b, in_a)            -- send data via serial port
  end loop

  pata_hd_stop_read()                     -- tell drive we are done reading
@@ -407,6 +423,8 @@
        <p>If you want, you can turn off the hard drive motor at the end of  
the program</p>
        <codeblock>-- We&apos;re done, lets turn off the hd motor
  pata_hd_register_write (PATA_HD_COMMAND_REG,PATA_HD_SPIN_DOWN)</codeblock>
+    </section>
+    <section>
        <title>Your Done!</title>
        <p>That&apos;s it, Now you can read &amp; write to all those hard  
drives you have laying around. You can read raw data from drives and  
possibly even get back some lost data.</p>
        <p>Alright,  go build that hard disk thingy you where dreaming  
about!</p>
=======================================
--- /trunk/doc/dita/tutorials/tutorial_sd_card.xml      Fri Nov 27 21:27:18 2009
+++ /trunk/doc/dita/tutorials/tutorial_sd_card.xml      Thu Dec  3 23:15:31 2009
@@ -24,19 +24,23 @@
        <p>We are not responsible for your data or SD card. Make sure you  
have nothing important on your SD card before you continue.</p>
        <image href="images/sd_card_sd_card.jpg" width="250"/>
        <image href="images/sd_card_pinout.jpg" width="300"/>
+      <p>These SD Cards are 3.3v devices, therefore a 5v to 3v conversion  
is needed between the PIC and the sd card. We will use resistors to do the  
conversion, however there are many other methods. See <xref  
href="http://www.microchip.com/3v/";  
format="html">http://www.microchip.com/3v/</xref> for more information.  
Another setup may be needed if you are putting more devices on the same SPI  
bus.</p>
+      <p>This circuit will use 16F877 If you are using a different PIC for  
your project, refer to the PIC&apos;s datasheet for pin output  
levels/voltage. For example, 18F452 has many pins that are 5v-input that  
give 3v-output. These pins show as &quot;TTL / ST&quot; - TTL compatible  
with CMOS level outputs in the datasheet and they will not require any  
voltage conversion resistors. If you are not sure, set a pin as an output,  
and make it go high then test with a volt meter.</p>
      </section>
      <section>
-      <p>These SD Cards are 3.3v devices, therefore a 5v to 3v conversion  
is needed between the PIC and the sd card. We will use resistors to do the  
conversion, however there are many other methods. See <xref  
href="http://www.microchip.com/3v/";  
format="html">http://www.microchip.com/3v/</xref> for more information.  
Another setup may be needed if you are putting more devices on the same SPI  
bus.</p>
-      <p>This circuit will use 16F877 If you are using a different PIC for  
your project, refer to the PIC&apos;s datasheet for pin output  
levels/voltage. For example, 18F452 has many pins that are 5v-input that  
give 3v-output. These pins show as &quot;TTL / ST&quot; - TTL compatible  
with CMOS level outputs in the datasheet and they will not require any  
voltage conversion resistors.</p>
        <title>Build a SD Card Slot</title>
        <p>Before we can build our circuit, we will need to find ourselves  
an sd card slot that can plug into our breadboard. You can find pre-made sd  
card slots on ebay and other places around the net. It is quite easy to  
make your own anyways. I took one out of a broken digital camera and placed  
it on some blank breadboard and soldered on some pins. Here are some images  
of my sd card holder:</p>
        <image href="images/sd_card_holder_front.jpg" width="200"  
otherprops="clickable"/>
        <image href="images/sd_card_holder_back.jpg" width="200"  
otherprops="clickable"/>
        <image href="images/sd_card_holder_with_card.jpg" width="200"  
otherprops="clickable"/>
+    </section>
+    <section>
        <title>Build the circuit</title>
        <p>Follow this schematic for 16f877, if you are using another PIC,  
check the pin-outs for the SPI bus. The pin-outs of your pic will show SDI,  
SDO, SCL and SS. The pin SS is the chip select pin, you can use any pin for  
it but the others must match.</p>
        <image href="images/sd_card_schematic.jpg" width="500"  
otherprops="clickable"/>
        <image href="images/sd_card_circuit.jpg" width="500"  
otherprops="clickable"/>
+    </section>
+    <section>
        <title>Compile and write the software to your PIC</title>
        <p>With the use of the sd card lib (sd_card.jal) and a sample file  
16f877_sd_card.jal, we can easily put one in our own circuit for mass data  
storage! You will find these files in the lib &amp; sample directories of  
your jallib installation. </p>
        <p>The most up to date version of the sample &amp; library can be  
found at:</p>
@@ -44,6 +48,8 @@
        <p>Library file - <xref  
href="http://jallib.googlecode.com/svn/trunk/include/external/storage/sd_card/sd_card.jal";
  
format="html">http://jallib.googlecode.com/svn/trunk/include/external/storage/sd_card/sd_card.jal</xref></p>
        <p>Now that our circuit is built, lets test it and make sure it  
works before we continue with more details. Compile and program your pic  
with 16f877_sd_card.jal from your jallib samples directory. If you are  
using another pic, change the &quot;include 16f877&quot; line in  
16f877_sd_card.jal to specify your PIC before compiling. </p>
        <p>Now that you have compiled it, burn the .hex file to your PIC</p>
+    </section>
+    <section>
        <title>Power It Up</title>
        <p>Plug your circuit into your PC for serial port communication at  
38400 baud rate. Now turn it on. Press the reset button in your circuit,  
you should get a result similar to this:</p>
        <b>ASCII output</b>
@@ -52,6 +58,8 @@
        <image href="images/sd_card_serial_data.jpg" width="450"  
otherprops="clickable"/>
        <p>As you can see from the first image, we got some actual readable  
data off the sd card as well as a bunch of junk. The sample file reads the  
first sector (512 bytes) from the sd card. My sd card is formated with  
fat32, this is why I can read some of the data output.</p>
        <p>In the second image (after clearing the output and resetting the  
circuit), there was too much data to show it all. It only shows the last  
bytes received. If you get the same hex output &quot;66 22&quot; followed  
by many &quot;00&quot;, your circuit has successfully written data and read  
it back again. You now have a working sd card circuit!</p>
+    </section>
+    <section>
        <title>Understand and modify the code</title>
        <p>I&apos;m just going to quickly go over some of the key points you  
need to know about sd cards. Open the sample file with an editor if you  
have not done so already.</p>
        <p>The code in the sample file may change,
@@ -66,6 +74,8 @@
  --
  pragma target WDT  disabled
  pragma target LVP  disabled</codeblock>
+      <p><b>Disable Analog Pins</b></p>
+      <codeblock>enable_digital_io() -- disable all analog pins if  
any</codeblock>
        <p/>
        <p><b>Include other libraries required</b></p>
        <codeblock>-- include the delay library
@@ -79,6 +89,7 @@
        <p/>
        <p><b>SPI Settings</b></p>
        <p>Here you may change the chip select pin &quot;pin_SS&quot; and  
&quot;pin_SS_direction&quot; to another pin. SDI, SDO and SCK must stay the  
same for the SPI hardware library.</p>
+      <p>You may notice that we are not defining/aliasing pins sdi, sdo  
and sck. We do not need to define them with a line like &quot;alias pin_sdo  
is pin_c5&quot; becase they are set within the PIC and cannot be changed.  
If we use the SPI hardware library, we must use the spi hardware pins.  We  
only need to define there direction  like this &quot;pin_sdo_direction =  
output&quot;.</p>
        <p>You may also choose the SPI rate. According to the SPI hardware  
library, you can use SPI_RATE_FOSC_4 SPI_RATE_FOSC_16, SPI_RATE_FOSC_64 or  
SPI_RATE_TMR. The fastest is FOSC_4 (oscillator frequency / 4). You may  
require a breadboard for the fastest speed, keep your SD Card as close to  
the PIC as possible.</p>
        <codeblock>-- setup spi
  include spi_master_hw         -- includes the spi library
@@ -96,7 +107,10 @@
  </codeblock>
        <p/>
        <p><b>Include the SD card library</b></p>
+      <p>Select sd card settings &amp; Include the library file, then  
initalize the sd card.</p>
+      <p>Some sd cards may require a 10ms delay every time you stop  
writing to the sd card, you can choose weater or not to have this delay. If  
you are doing many small writes and are worried about speed, you may set  
SD_DELAY_AFTER_WRITE to &quot;FALSE&quot;.</p>
        <codeblock>-- setup sd card library
+const bit SD_DELAY_AFTER_WRITE = TRUE
  include sd_card -- include sd card library
  sd_init()       -- initalize the sd card</codeblock>
        <p/>
=======================================
--- /trunk/doc/dita/tutorials/tutorials.ditamap Fri Nov 27 21:27:18 2009
+++ /trunk/doc/dita/tutorials/tutorials.ditamap Thu Dec  3 23:15:31 2009
@@ -26,7 +26,7 @@
    </frontmatter>
    <chapter href="tutorial_basics.xml">
      <topicref navtitle="TODO: Introduction"/>
-    <topicref href="installation.xml"/>
+    <topicref href="tutorial_installation.xml"/>
      <topicref href="tutorial_getting_started.xml"/>
      <topicref href="tutorial_blink_a_led.xml"/>
      <topicref navtitle="Setting up a serial link (UART) -- TODO"/>

--

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.


Reply via email to