Editing Dosonchip

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
== NEW FIRMWARE & ROYALTY-FREE API C SOURCE CODE AVAILABLE (MANY IMPROVEMENTS) ==
+
The DOSOnChip module is perhaps the most poorly documented piece of technology I've yet come across. After many days of trying to get this thing to communicate via SPI, I finally have it working. However, some caveats:
There is a new host interface with royalty-free host-side C source code available direct from the DOSonCHIP website:
 
  
http://dosonchip.com
+
DosOnChip "SPI" for Dummies (IE, me two days ago):
  
that works with the new firmware version 2.xx which is available on all new chips.
+
1. SPI
 
 
-SDHC up to 32GB is supported.
 
-Speeds are MUCH MUCH faster.
 
-The SPI interface is now a true SPI interface without the need for the DIR and BUSY handshake signals.
 
-The UART interface only requires 2-pins: RX and TX (hardware handshake signals are optional (UART_CTS should be set to GND if not used).
 
-New functionality.
 
 
 
 
 
 
 
= PLEASE NOTE THAT THE SUBSEQENT INFORMATION APPLIES TO FIRMWARE VERSIONS 1.xx =
 
 
 
 
 
 
 
Host communication via SPI:
 
 
 
"SPI" for Dummies (IE, me two days ago):
 
 
 
1. SPI (see any SPI tutorial website for more info)
 
  
 
SPI is a four-wire interface consisting of the following signals:
 
SPI is a four-wire interface consisting of the following signals:
Line 52: Line 33:
 
Aside from VCC and GND, these are assigned to bits in the header file in the first code section below.
 
Aside from VCC and GND, these are assigned to bits in the header file in the first code section below.
  
Notes:
+
== WHY THIS ISN'T SPI ==
  
1. When using only one device on SPI, you should be able to leave the CS  signal in the active state at all times, also called "3 wire mode." The DOSOnChip module (DOC for short) recommends that you wiggle this pin as part of its communications protocol in noisy environments (more later).
 
  
2. In addition to the above signals, DOC requires that you monitor an additional pins: BUSY.
+
1. When using only one device on SPI, you should be able to leave the CS  signal in the active state at all times, also called "3 wire mode." The DOSOnChip module (DOC for short) requires that you wiggle this pin as part of its communications protocol (more later).
  
3. DOC requires that you toggle the RESET pin to reset the device. It is possible to put the module to sleep via SPI, but reawakening the device requires that you disconnect power and reapply it. Even toggling the RESET pin will not cause the device to wake up.  
+
2. In addition to the above signals, DOC requires that you monitor two additional pins: BUSY and DIR. Now we're up to six pins (not including the power supply) which is not in accordance with SPI.
 +
 
 +
3. DOC requires that you toggle the RESET pin to reset the device. While I understand this from a design point of view, it should be possible to reset the device via an SPI command. It IS possible to put the module to sleep via SPI, but reawakening the device requires that you disconnect power and reapply it. Even toggling the RESET pin will not cause the device to wake up.  
  
 
So, the "SPI"-like interface consists of the following signals:
 
So, the "SPI"-like interface consists of the following signals:
  
 +
SCLK - clock. This pin is normally low, and must be toggled up and down to write or read a bit. (two transitions per bit).
 +
MISO - master in/slave (DOC) out
 +
MOSI - master out/ slave (DOC) in
 +
CS - ChipSelect
 +
DIR - read only from master point-of-view. DOC sets this to 1 when it is ready to receive data, and sets it to 0 when it has data to send.
 +
BUSY - Read-only from master point of view. DOC sets this to 1 when it can't be bothered to communicate.
 +
RESET - used to reset or intialize the device.
  
'''SCLK''' - clock. Must be toggled up and down to write or read a bit. (two transitions per bit).
+
That gives us 7 signals. Personally, when I order a device that advertises itself as SPI compatible, I expect to be able to drive it with the host controller's SPI system. Especially when I am using a Silicon Labs C8051F124, a close cousin of the C8051F310 that DOC burns their firmware into and sells as their own device. Since both SPI systems were designed by the same people, you'd think they could talk to each other. However, getting this to work within the context of the SPI interrupt handler is difficult. I wound up using a spare timer interrupt instead so I could have bit- and clock-level control.
  
'''MISO''' - master in/slave (DOC) out
+
== OTHER COMPLAINTS ==
  
'''MOSI''' - master out/ slave (DOC) in
 
  
'''CS''' - ChipSelect
+
The documentation for this device is inadequate. SparkFun should point this out on their product page, or, if they plan on continuing to hawk this device, obtain or write some example code or at least a short pdf with, at very least, an accurate timing diagram. The PDF datasheet for the DOC has no timing specifications, no example code (one section includes the directive "Insert Pseudocode Here") no mention of the case-sensitivity of the command interpreter.
  
'''DIR''' - read only from master point-of-view. DOC sets this to 1 when it is ready to receive data, and sets it to 0 when it has data to send.
+
The device tends to spit out an extra bit or two after reset which throws the byte-level SPI buffer on my mcu out of sync. In my timer interrupt, I shift each bit into an unsigned int (2 bytes) until the int is equal to 0x0D3E, the prompt string from the DOC. At that point, I set a "synchronized" flag to true and assume that the next bit starts a new byte. This usually necessitates tossing out a few bits at the beginning.  
  
'''BUSY''' - Read-only from master point of view. DOC sets this to 1 when it can't be bothered to communicate.
 
 
'''RESET''' - used to reset or intialize the device.
 
 
That gives us 7 signals. Personally, when I order a device that advertises itself as SPI compatible, I expect to be able to drive it with the host controller's SPI system. Especially when I am using a Silicon Labs C8051F124, a close cousin of the C8051F310 that DOC burns their firmware into and sells as their own device. Since both SPI systems were designed by the same people, you'd think they could talk to each other. However, getting this to work within the context of the SPI interrupt handler is difficult. I wound up using a spare timer interrupt instead so I could have bit- and clock-level control.
 
  
 +
== NOTES ==
  
The documentation for this device is inadequate. The PDF datasheet for the DOC has no timing specifications, no example code (one section includes the directive "Insert Pseudocode Here") no mention of the case-sensitivity of the command interpreter. However, new documentation is planned for later in 2007.
 
  
 +
+ Your device should NEVER write to the BUSY or DIR pins. Doing so will cause very strange things to happen.
  
== NOTES ==
+
+ After sending a complete command (which may be multiple bytes), you must toggle the CS line to inform the DOC that you have completed sending a command. If its firmware were well-written, it would be able to tell this by the fact that you must ALSO send a 0x0D carriage return at the end of a command.
 
 
 
 
+ Your device should NEVER write to the BUSY or DIR pins as these are output pins on the DOC silicon. Doing so will cause very strange things to happen.
 
  
 
+ BUSY is set to a 1 by the DOC to tell you that it's, well, BUSY. This makes sense, but is not documented adequately.  
 
+ BUSY is set to a 1 by the DOC to tell you that it's, well, BUSY. This makes sense, but is not documented adequately.  
Line 96: Line 77:
 
When you get the DOC working, itms to remember:
 
When you get the DOC working, itms to remember:
  
+ commands must be LOWER CASE and filenames must be UPPER CASE (this follows the Microsoft FAT file naming convention).  
+
+ commands must be LOWER CASE and filenames must be UPPER CASE.  
  
 
+ To write data to a file:
 
+ To write data to a file:
  
+ The SD card must be formatted as FAT16 or FAT32 (not FAT12).
+
+ The SD card must be formatted as FAT 16.
  
+ when you attempt to use a file or directory name with LOWERCASE, even if is a FAT16 file structure, DOC will respond with an error -14, "Long Filenames Not Supported." Note that a filename like "aadsf.txt," is not 8.3-filename (FAT16) compliant - this should be "AADSF.TXT".
+
+ when you attempt ot use a file or directory name with LOWERCASE, even if is a FAT 16 file structure, DOC will respond with an error -14, "Long Filenames Not Supported." This is confusing when using a filename like "aadsf.txt," wich is 8.3-filename (FAT16) compliant.
  
 
<pre>
 
<pre>
Line 133: Line 114:
 
</code>
 
</code>
  
== SUMMARY ==
+
== SUMMARY AND IMPRESSIONS ==
  
  
 
That's about it. I had some issues with receiving bit streams that were off by a bit because the DOC clocks data out and in on different edges, so if your clock transition is 1-0-1 instead of 0-1-0, you'll drop the last bit of the transmission and the first bit you receive will be incorrect.  
 
That's about it. I had some issues with receiving bit streams that were off by a bit because the DOC clocks data out and in on different edges, so if your clock transition is 1-0-1 instead of 0-1-0, you'll drop the last bit of the transmission and the first bit you receive will be incorrect.  
  
Now that I have this thing working, it's great.  
+
Now that I have this thing working, it's great. It's interesting that the DOC is a processor almost as powerful than I am using to drive two OLEDs, a GPS receiver and the DOC itself in addition to JTAG and a serial interface to my PC, and it doesn't provide sufficiently correct errors (Long Filenames Not SUpported?! "ASDF.TXT" is not a LONG FILENAME!) or diagnostic information.  
  
== CODE for the C8051F124 ==
+
My ISR is attached to a post above for anyone who wants to study it. Please do not reuse this code in any commercial apps, but you're welcome to use it as a reference for your own designs.
My ISR is attached to a post above for anyone who wants to study it. Please do not  
 
reuse this code in any commercial apps, but you're welcome to use it as a reference  
 
for your own designs.
 
  
 
First, the header file SPI.H:
 
First, the header file SPI.H:
Line 184: Line 162:
 
SPI.C
 
SPI.C
  
This is a mock-SPI interface for the DOSOnChip module,
+
This is a mock-SPI interface for the DOSOnChip module, written in Keil C for the Silicon Labs C8051F124.
written in Keil C for the Silicon Labs C8051F124.All code  
+
All code is copyright 2007 by Steven David Lively (david.lively@arm.com) and may not be reused in a commercial product without my permission.
is copyright 2007 by Steven David Lively (david dot lively at arm)  
 
and may not be reused in a commercial product without  
 
my permission.
 
  
 
*/
 
*/
Line 432: Line 407:
 
}
 
}
 
</pre>
 
</pre>
 
== related ==
 
 
* [http://www.sparkfun.com/commerce/product_info.php?products_id=7955 Breakout Board with DOSonCHIP + SD socket]
 
* [http://www.sparkfun.com/commerce/product_info.php?products_id=8215 Breakout Board with DOSonCHIP + micro-SD socket]
 
* [http://www.sparkfun.com/commerce/product_info.php?products_id=7956 DOSonCHIP]
 
* DOSonCHIP Website http://dosonchip.com/
 
* [http://chipdos.com/library/CD17B10_User_Guide_0v1.pdf CD17B10 User Guide]
 
* [http://chipdos.com/library/CD17Bxx-0v8.pdf CD17Bxx Datasheet]
 
 
Alternatives:
 
 
See the many alternatives at [[MMC]].
 

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)