|
|
(10 intermediate revisions by one user not shown) |
Line 112: |
Line 112: |
| |- valign="baseline" style="vertical-align: baseline;" | | |- valign="baseline" style="vertical-align: baseline;" |
| | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> | | | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> |
− | | Interface functions (drivers) for [http://avrhelp.mcselec.com/compact_flashcard_driver.htm Compact Flash], hard disk, SD-Cards, SDHC (also microSD or microSDHC). See SD and SDHC pinout below. | + | | Interface functions (drivers) for [[Compact_FlashCard_Driver|Compact Flash]], hard disk, SD-Cards, SDHC (also microSD or microSDHC). See SD and SDHC pinout below. |
| |} | | |} |
| </div> | | </div> |
| | | |
| | | |
− | See also: [http://avrhelp.mcselec.com/new_cf_card_drivers.htm New CF-Card Drivers], [http://avrhelp.mcselec.com/elektor_cf_interface.htm Elektor CF-Interface] | + | See also: [[New_CF-Card_Drivers|New CF-Card Drivers]], [[Elektor_CF-Interface|Elektor CF-Interface]] |
| | | |
| | | |
Line 183: |
Line 183: |
| | | |
| | | |
− | http://avrhelp.mcselec.com/notice.jpgNote that it is not permitted to use the AVR-DOS file system for commercial applications without the purchase of a license. A license comes with the ASM source. You can buy a user license that is suited for most private users.
| + | [[File:Notice.jpg]] Note that it is not permitted to use the AVR-DOS file system for commercial applications without the purchase of a license. A license comes with the ASM source. You can buy a user license that is suited for most private users. |
| | | |
| When you develop a commercial product with AVR-DOS you need the company license. The ASM source is shipped with both licenses. | | When you develop a commercial product with AVR-DOS you need the company license. The ASM source is shipped with both licenses. |
Line 219: |
Line 219: |
| <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);"> </span> | | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);"> </span> |
| | | |
− | For SD-cards <span style="text-decoration: underline;">and SDHC cards</span> (works also with ATXMEGA !):<br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$include</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"config_MMCSD_HC.inc"</span> | + | For SD-cards <span style="text-decoration: underline;">and SDHC cards</span> (works also with ATXMEGA !):<br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$include</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"config_MMCSD_HC.inc"</span> |
| | | |
| <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);"> </span> | | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);"> </span> |
| | | |
− | 2. After calling the Driver interface library you need check the Error Byte which is <span style="font-weight: bold;">Gbdriveerror </span>and which is output of the function <span style="font-size: 12pt; font-family: 'Times New Roman';">[http://avrhelp.mcselec.com/driveinit.htm DRIVEINIT()]. </span>If the output is 0 (no error) you can include the AVR-DOS configuration file. Otherwise you should output the error number. | + | 2. After calling the Driver interface library you need check the Error Byte which is <span style="font-weight: bold;">Gbdriveerror </span>and which is output of the function <span style="font-size: 12pt; font-family: 'Times New Roman';">[[DriveInit|DRIVEINIT()]]. </span>If the output is 0 (no error) you can include the AVR-DOS configuration file. Otherwise you should output the error number. |
| | | |
| <span style="font-weight: bold;"> </span> | | <span style="font-weight: bold;"> </span> |
Line 235: |
Line 235: |
| <span style="font-family: Arial;"> </span> | | <span style="font-family: Arial;"> </span> |
| | | |
− | <span style="font-family: Arial;">3. </span>In case of <span style="font-weight: bold;">Gbdriveerror = 0</span> (No Error) you can Initialize the file system with [http://avrhelp.mcselec.com/initfilesystem.htm INITFILESYSTEM](1) where 1 is the partition number. For the Error Output var you need to dim a byte variable like <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Btemp1 </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span> wbefore you call the Initfilesystem. | + | <span style="font-family: Arial;">3. </span>In case of <span style="font-weight: bold;">Gbdriveerror = 0</span> (No Error) you can Initialize the file system with [[INITFILESYSTEM]](1) where 1 is the partition number. For the Error Output var you need to dim a byte variable like <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Btemp1 </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span> wbefore you call the Initfilesystem. |
| | | |
| | | |
Line 245: |
Line 245: |
| With Btemp1 = 0 (no error) the <span style="font-weight: bold;">Filesystem is successfully initialized</span> and you can use all other AVR-DOS functions like open, close, read and write. | | With Btemp1 = 0 (no error) the <span style="font-weight: bold;">Filesystem is successfully initialized</span> and you can use all other AVR-DOS functions like open, close, read and write. |
| | | |
− | Functions like [http://avrhelp.mcselec.com/put.htm PUT], [http://avrhelp.mcselec.com/get.htm GET], [http://avrhelp.mcselec.com/seek.htm SEEK-Set] only work when the file is opened in binary mode for example: <span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"test.bin"</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Binary</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">2</span> | + | Functions like [[PUT]], [[GET]], [[SEEK]]-Set only work when the file is opened in binary mode for example: <span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"test.bin"</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Binary</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">2</span> |
| | | |
| | | |
Line 251: |
Line 251: |
| | | |
| | | |
− | When you want change (ejecting from the card socket) the SD-card (during the AVR is running other code than AVR-DOS) you need to call <span style="font-size: 12pt; font-family: 'Times New Roman';">[http://avrhelp.mcselec.com/driveinit.htm DRIVEINIT()] and </span>[http://avrhelp.mcselec.com/initfilesystem.htm INITFILESYSTEM](1) again in order to reset the AVR-Hardware (PORTs, PINs) attached to the Drive,reset the Drive again and initialize the file system again. | + | When you want change (ejecting from the card socket) the SD-card (during the AVR is running other code than AVR-DOS) you need to call <span style="font-size: 12pt; font-family: 'Times New Roman';">[[DriveInit|DRIVEINIT()]] and </span>[[INITFILESYSTEM]](1) again in order to reset the AVR-Hardware (PORTs, PINs) attached to the Drive,reset the Drive again and initialize the file system again. |
| | | |
| <span style="font-family: Arial;"> </span> | | <span style="font-family: Arial;"> </span> |
Line 295: |
Line 295: |
| | | |
| | | |
− | For example by setting <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cfilehandles </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1 </span>and handling of FAT- and DIR-Buffer in one SRAM buffer with 561 bytes). You will not have much SRAM left anyway for other tasks in the ATMEGA32 and you can not expect maximum performance. [http://avrhelp.mcselec.com/_hwstack.htm $HWSTACK], [http://avrhelp.mcselec.com/_swstack.htm $SWSTACK] and [http://avrhelp.mcselec.com/_framesize.htm $FRAMESIZE] also needs to be set carefully. | + | For example by setting <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cfilehandles </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1 </span>and handling of FAT- and DIR-Buffer in one SRAM buffer with 561 bytes). You will not have much SRAM left anyway for other tasks in the ATMEGA32 and you can not expect maximum performance. [[$HWSTACK]], [[$SWSTACK]] and [[$FRAMESIZE]] also needs to be set carefully. |
| | | |
| | | |
Line 309: |
Line 309: |
| <span style="color: rgb(0, 0, 255);"> </span> | | <span style="color: rgb(0, 0, 255);"> </span> |
| | | |
− | With the above configuration and with the filename there is approximately 500 byte SRAM left in an ATMEGA32 for other tasks. Or in other words AVR-DOS needs at least <span style="font-weight: bold;">1500 Byte SRAM</span> in this case. To get detailed values compile your AVR-DOS application and open the <span style="font-weight: bold;">Bascom-AVR compiler Report (CTRL+W)</span> then you see the value with <span style="font-style: italic;">Space left : 508 Bytes</span> (then you have 508 Bytes left for other tasks). | + | With the above configuration and with the filename there is approximately 500 byte SRAM left in an ATMEGA32 for other tasks. Or in other words AVR-DOS needs at least <span style="font-weight: bold;">1500 Byte SRAM</span> in this case. To get detailed values compile your AVR-DOS application and open the <span style="font-weight: bold;">Bascom-AVR compiler Report (CTRL+W)</span> then you see the value with <span style="font-style: italic;">Space left : 508 Bytes</span> (then you have 508 Bytes left for other tasks). |
| | | |
| <span style="font-size: 8pt; font-family: Courier;"> </span> | | <span style="font-size: 8pt; font-family: Courier;"> </span> |
Line 323: |
Line 323: |
| <span style="font-size: 8pt; font-family: Courier;"> </span> | | <span style="font-size: 8pt; font-family: Courier;"> </span> |
| | | |
− | <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Append</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">100</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">100 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"This is what I log to SD-Card !"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">100</span> | + | <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Append</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">100</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">100 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"This is what I log to SD-Card !"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">100</span> |
| | | |
| <span style="font-size: 8pt; font-family: Courier;"> </span> | | <span style="font-size: 8pt; font-family: Courier;"> </span> |
Line 909: |
Line 909: |
| | | |
| = <span class="f_Header">Error Codes</span> = | | = <span class="f_Header">Error Codes</span> = |
− |
| |
− | <span class="f_Header"> </span>
| |
| <div style="padding: 0px; margin: 0px 0px 0px 4px;"> | | <div style="padding: 0px; margin: 0px 0px 0px 4px;"> |
− | {| width="623" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;" | + | {| cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;" |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" bgcolor="#ffff99" style="width: 88px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" bgcolor="#ffff99" style="width: 164px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" | |
| <span style="font-weight: bold;">Code</span> | | <span style="font-weight: bold;">Code</span> |
| | | |
− | | valign="top" width="100%" bgcolor="#ffff99" style="width: 452px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" bgcolor="#ffff99" style="width: 270px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" | |
| <span style="font-weight: bold;">Compiler – Alias</span> | | <span style="font-weight: bold;">Compiler – Alias</span> |
| | | |
− | | valign="top" width="100%" bgcolor="#ffff99" style="width: 71px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" bgcolor="#ffff99" style="width: 534px; background-color: rgb(255, 255, 153); border: 1px solid rgb(0, 0, 0);" | |
| <span style="font-weight: bold;">Remark</span> | | <span style="font-weight: bold;">Remark</span> |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 0 | | 0 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpNoError | | cpNoError |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| No Error | | No Error |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 1 | | 1 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpEndOfFile | | cpEndOfFile |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Attempt behind End of File | | Attempt behind End of File |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 17 | | 17 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpNoMBR | | cpNoMBR |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Sector 0 on Card is not a Master Boot Record | | Sector 0 on Card is not a Master Boot Record |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 18 | | 18 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpNoPBR | | cpNoPBR |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| No Partition Sector | | No Partition Sector |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 19 | | 19 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileSystemNotSupported | | cpFileSystemNotSupported |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Only FAT16 File system is supported | | Only FAT16 File system is supported |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 20 | | 20 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpSectorSizeNotSupported | | cpSectorSizeNotSupported |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Only sector size of 512 Bytes is supported | | Only sector size of 512 Bytes is supported |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 21 | | 21 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpSectorsPerClusterNotSupported | | cpSectorsPerClusterNotSupported |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Only 1, 2, 4, 8, 16, 32, 64 Sectors per Cluster is supported. This are values of normal formatted partitions. Exotic sizes, which are not power of 2 are not supported | | Only 1, 2, 4, 8, 16, 32, 64 Sectors per Cluster is supported. This are values of normal formatted partitions. Exotic sizes, which are not power of 2 are not supported |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| + | 22 |
| + | |
| + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| + | Cpcountofclustersnotsupported |
| + | |
| + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| + | The number of clusters is not supported |
| + | |
| + | |- style="vertical-align: top;" |
| + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 33 | | 33 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpNoNextCluster | | cpNoNextCluster |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Error in file cluster chain | | Error in file cluster chain |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 34 | | 34 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpNoFreeCluster | | cpNoFreeCluster |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| No free cluster to allocate (Disk full) | | No free cluster to allocate (Disk full) |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 35 | | 35 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpClusterError | | cpClusterError |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Error in file cluster chain | | Error in file cluster chain |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 49 | | 49 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpNoFreeDirEntry | | cpNoFreeDirEntry |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Directory full | | Directory full |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 50 | | 50 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileExist | | cpFileExist |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
− | <span style="font-family: Arial;"> </span> | + | <span style="font-family: Arial;">File exists</span> |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; height: 14px; border: 1px solid rgb(0, 0, 0);" | |
| + | 51 |
| + | |
| + | | valign="top" width="28%" style="width: 270px; height: 14px; border: 1px solid rgb(0, 0, 0);" | |
| + | Cpfiledeletenotallowed |
| + | |
| + | | valign="top" width="92%" style="width: 534px; height: 14px; border: 1px solid rgb(0, 0, 0);" | |
| + | File may not be deleted |
| + | |
| + | |- style="vertical-align: top;" |
| + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| + | 52 |
| + | |
| + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| + | Cpsubdirectorynotempty |
| + | |
| + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| + | Sub directory not empty.You can not delete sub folders which contain files |
| + | |
| + | |- style="vertical-align: top;" |
| + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| + | 53 |
| + | |
| + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| + | Cpsubdirectoryerror |
| + | |
| + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| + | Sub directory error |
| + | |
| + | |- style="vertical-align: top;" |
| + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| + | 54 |
| + | |
| + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| + | Cpnotasubdirectory |
| + | |
| + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | <br/> |
| + | |- style="vertical-align: top;" |
| + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 65 | | 65 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpNoFreeFileNumber | | cpNoFreeFileNumber |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| No free file number available, only theoretical error, if 255 file handles in use | | No free file number available, only theoretical error, if 255 file handles in use |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 66 | | 66 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileNotFound | | cpFileNotFound |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| File not found | | File not found |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 67 | | 67 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileNumberNotFound | | cpFileNumberNotFound |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| No file handle with such file number | | No file handle with such file number |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 68 | | 68 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileOpenNoHandle | | cpFileOpenNoHandle |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| All file handles occupied | | All file handles occupied |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 69 | | 69 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileOpenHandleInUse | | cpFileOpenHandleInUse |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| File handle number in use, can't create a new file handle with same file number | | File handle number in use, can't create a new file handle with same file number |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 70 | | 70 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileOpenShareConflict | | cpFileOpenShareConflict |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Tried to open a file in read and write modus in two file handles | | Tried to open a file in read and write modus in two file handles |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 71 | | 71 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileInUse | | cpFileInUse |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Can't delete file, which is in use | | Can't delete file, which is in use |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 72 | | 72 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileReadOnly | | cpFileReadOnly |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| Can't open a read only file for writing | | Can't open a read only file for writing |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 73 | | 73 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileNoWildCardAllowed | | cpFileNoWildCardAllowed |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| No wildcard allowed in this function | | No wildcard allowed in this function |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| + | 74 |
| + | |
| + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| + | Cpfilenumberinvalid |
| + | |
| + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| + | <span style="font-family: Arial;">Invalid file number</span> |
| + | |
| + | |- style="vertical-align: top;" |
| + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 97 | | 97 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFilePositionError | | cpFilePositionError |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| <span style="font-family: Arial;"> </span> | | <span style="font-family: Arial;"> </span> |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 98 | | 98 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileAccessError | | cpFileAccessError |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| function not allowed in this file open mode | | function not allowed in this file open mode |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 99 | | 99 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpInvalidFilePosition | | cpInvalidFilePosition |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| new file position pointer is invalid (minus or 0) | | new file position pointer is invalid (minus or 0) |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
− | | valign="top" width="17%" style="width: 88px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| 100 | | 100 |
| | | |
− | | valign="top" width="100%" style="width: 452px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| cpFileSizeToGreat | | cpFileSizeToGreat |
| | | |
− | | valign="top" width="100%" style="width: 71px; border: 1px solid rgb(0, 0, 0);" | | + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | |
| File size to great for function BLoad | | File size to great for function BLoad |
| | | |
| + | |- style="vertical-align: top;" |
| + | | valign="top" width="17%" style="width: 164px; border: 1px solid rgb(0, 0, 0);" | |
| + | &HC0 |
| + | |
| + | | valign="top" width="28%" style="width: 270px; border: 1px solid rgb(0, 0, 0);" | |
| + | Cpdrivererrorstart |
| + | |
| + | | valign="top" width="92%" style="width: 534px; border: 1px solid rgb(0, 0, 0);" | <br/> |
| |} | | |} |
| </div> | | </div> |
− | <span style="font-family: Arial;"> </span>
| |
− |
| |
− | <span style="font-family: Arial;"> </span>
| |
− |
| |
| <span style="font-family: Arial;"> </span> | | <span style="font-family: Arial;"> </span> |
| | | |
Line 1,216: |
Line 1,276: |
| | | |
| | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,235: |
Line 1,295: |
| | | |
| | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,254: |
Line 1,314: |
| | | |
| | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,267: |
Line 1,327: |
| | | |
| | valign="top" width="9%" style="width: 53px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="9%" style="width: 53px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="9%" style="width: 53px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="9%" style="width: 53px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,289: |
Line 1,349: |
| | | |
| | valign="top" width="9%" style="width: 53px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="9%" style="width: 53px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,311: |
Line 1,371: |
| | | |
| | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="14%" style="width: 84px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="23%" style="width: 140px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,358: |
Line 1,418: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,374: |
Line 1,434: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,399: |
Line 1,459: |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,415: |
Line 1,475: |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,422: |
Line 1,482: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,438: |
Line 1,498: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,454: |
Line 1,514: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,463: |
Line 1,523: |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,470: |
Line 1,530: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,495: |
Line 1,555: |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,502: |
Line 1,562: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,511: |
Line 1,571: |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,521: |
Line 1,581: |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,534: |
Line 1,594: |
| | | |
| | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 39px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
Line 1,543: |
Line 1,603: |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |- style="vertical-align: top;" | | |- style="vertical-align: top;" |
Line 1,553: |
Line 1,613: |
| | | |
| | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 50px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 55px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | | | | valign="top" width="100%" style="width: 47px; height: 4px; border: 1px solid rgb(0, 0, 0);" | |
− | http://avrhelp.mcselec.com/dot.gif
| + | [[File:Dot.gif]] |
| | | |
| |} | | |} |
Line 1,575: |
Line 1,635: |
| <span style="font-family: Arial;"> </span> | | <span style="font-family: Arial;"> </span> |
| | | |
− | [http://avrhelp.mcselec.com/initfilesystem.htm INITFILESYSTEM] , [http://avrhelp.mcselec.com/open.htm OPEN] , [http://avrhelp.mcselec.com/close.htm CLOSE], [http://avrhelp.mcselec.com/flush.htm FLUSH] , [http://avrhelp.mcselec.com/print.htm PRINT], [http://avrhelp.mcselec.com/line_input.htm LINE INPUT], [http://avrhelp.mcselec.com/loc.htm LOC], [http://avrhelp.mcselec.com/lof.htm LOF] , [http://avrhelp.mcselec.com/eof.htm EOF] , [http://avrhelp.mcselec.com/freefile.htm FREEFILE] , [http://avrhelp.mcselec.com/fileattr.htm FILEATTR] , [http://avrhelp.mcselec.com/seek.htm SEEK] , [http://avrhelp.mcselec.com/bsave.htm BSAVE] ,[http://avrhelp.mcselec.com/bload.htm BLOAD] , [http://avrhelp.mcselec.com/kill.htm KILL] , [http://avrhelp.mcselec.com/diskfree.htm DISKFREE] , [http://avrhelp.mcselec.com/disksize.htm DISKSIZE] , [http://avrhelp.mcselec.com/get.htm GET] , [http://avrhelp.mcselec.com/put.htm PUT] ,[http://avrhelp.mcselec.com/filedate.htm FILEDATE] , [http://avrhelp.mcselec.com/filetime.htm FILETIME] , [http://avrhelp.mcselec.com/filedatetime.htm FILEDATETIME] , [http://avrhelp.mcselec.com/dir.htm DIR] , [http://avrhelp.mcselec.com/write.htm WRITE] , [http://avrhelp.mcselec.com/input.htm INPUT] , [http://avrhelp.mcselec.com/filelen.htm FILELEN] | + | [[INITFILESYSTEM]] , [[OPEN]] , [[CLOSE]], [[FLUSH]] , [[PRINT]], [[LINE INPUT]], [[LOC]], [[LOF]] , [[EOF]] , [[FREEFILE]] , [[FILEATTR]] , [[SEEK]] , [[BSAVE]] ,[[BLOAD]] , [[KILL]] , [[DISKFREE]] , [[DISKSIZE]] , [[GET]] , [[PUT]] ,[[FILEDATE]] , [[FILETIME]] , [[FILEDATETIME]] , [[DIR]] , [[WRITE]] , [[INPUT]] , [[FILELEN]] |
| | | |
| | | |
Line 1,856: |
Line 1,916: |
| = <span class="f_Header">Example 1 for getting started with an ATMEGA and ATXMEGA with MMCSD_HC.LIB</span> = | | = <span class="f_Header">Example 1 for getting started with an ATMEGA and ATXMEGA with MMCSD_HC.LIB</span> = |
| | | |
− |
| + | <source lang="bascomavr"> |
| + | '------------------------------------------------------------------------------- |
| + | ' Filename: XMEGA_AVR-DOS_SDHC.BAS |
| + | ' Library needed: MMCSD_HC.LIB --> Place MMCSD_HC.LIB in the LIB-Path of BASCOM-AVR installation |
| + | ' MMCSD_HC.LIB will be called from config_MMCSD_HC.inc |
| + | ' AVR-DOS.Lbx |
| + | ' Include file: config_MMCSD_HC.inc (will be called from XMEGA_AVR-DOS_SDHC.BAS) |
| + | ' Used ATXMEGA: ATXMEGA128A1 |
| + | ' Used SPI Port: Port D (you can also use Software SPI) |
| + | '------------------------------------------------------------------------------- |
| + | ' |
| + | ' File Structure: |
| + | ' |
| + | ' +-------------------------------------------------+ |
| + | ' | XMEGA_AVR-DOS_SDHC.BAS | Main |
| + | ' +-------------------------------------------------+ |
| + | ' | | |
| + | ' +--------------------+ +----------------------+ |
| + | ' | config_MMCSD_HC.inc| | Config_AVR-DOS.inc | Include Files |
| + | ' +--------------------+ +----------------------+ |
| + | ' | | |
| + | ' +--------------------+ +----------------------+ |
| + | ' | MMCSD_HC.LIB | | AVR-DOS.Lbx | Libraries |
| + | ' +--------------------+ +----------------------+ |
| + | ' |
| + | ' |
| + | ' Terminal output of following example (with hardware SPI over Port.D): |
| + | ' |
| + | ' Used SD-Card: 4GByte SDHC Card |
| + | ' |
| + | ' |
| + | '( |
| + | |
| + | ---Example for using a SDHC-Card with AVR-DOS and XMEGA--- |
| + | Starting... SDHC with ATXMEGA.... |
| + | |
| + | SD Card Type = SDHC Spec. 2.0 or later |
| + | |
| + | Init File System ... OK --> Btemp1= 0 / Gbdriveerror = 0 |
| + | Filesystem = 6 |
| + | FAT Start Sector: 8196 |
| + | Root Start Sector: 8688 |
| + | Data First Sector: 8720 |
| + | Max. Cluster Nummber: 62794 |
| + | Sectors per Cluster: 128 |
| + | Root Entries: 512 |
| + | Sectors per FAT: 246 |
| + | Number of FATs: 2 |
| + | |
| + | |
| + | Write to file done ! |
| + | File length = 46 |
| + | This is my 1 first Text to File with XMEGA ! |
| + | write to file |
| + | Total bytes written: 10200 |
| + | Write and Readback test done ! |
| + | Dir function demo |
| + | LOGGER.TXT 01\01\01 01:00:00 3120 |
| + | MY_FILE.TXT 01\01\01 01:00:00 46 |
| + | TEST.TXT 01\01\01 01:00:00 10200 |
| + | |
| + | Diskfree = 4018560 |
| + | Disksize = 4018752 |
| + | |
| + | ') |
| + | |
| + | |
| + | $regfile = "xm128a1def.dat" |
| + | $crystal = 32000000 '32MHz |
| + | $hwstack = 128 |
| + | $swstack = 128 |
| + | $framesize = 128 |
| + | |
| + | |
| + | Config Osc = Disabled , 32mhzosc = Enabled '32MHz |
| + | Config Sysclock = 32mhz '32Mhz |
| + | Config Priority = Static , Vector = Application , Lo = Enabled 'config interrupts |
| + | Enable Interrupts |
| + | |
| + | '=====[ Serial Interface to PC = COM5 ]======================================== |
| + | Config Com5 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 |
| + | Open "COM5:" For Binary As #2 |
| + | Waitms 1 |
| + | |
| + | Print #2 , |
| + | Print #2 , "---Example for using a SDHC-Card with AVR-DOS and XMEGA---" |
| + | |
| + | '=====[ Global Vars ]========================================================== |
| + | Dim Btemp1 As Byte ' Needed for Fat Drivers |
| + | Dim Input_string As String * 100 |
| + | Dim Output_string As String * 100 |
| + | Dim File_handle As Byte |
| + | Dim File_name As String * 14 |
| + | Dim X As Long |
| + | |
| + | |
| + | |
| + | Print #2 , "Starting... SDHC with ATXMEGA...." |
| + | Print #2 , |
| + | |
| + | '------------------------------------------------------------------------------ |
| + | |
| + | '=====[ Includes ]============================================================ |
| + | |
| + | |
| + | $include "config_MMCSD_HC.inc" |
| + | |
| + | Print #2 , "SD Card Type = " ; |
| + | Select Case Mmcsd_cardtype |
| + | Case 0 : Print #2 , "can't init the Card" |
| + | Case 1 : Print #2 , "MMC" |
| + | Case 2 : Print #2 , "SDSC Spec. 1.x " |
| + | Case 4 : Print #2 , "SDSC Spec. 2.0 or later" |
| + | Case 12 : Print #2 , "SDHC Spec. 2.0 or later" |
| + | End Select |
| + | |
| + | Print #2 , |
| + | |
| + | |
| + | If Gbdriveerror = 0 Then 'from.... Gbdriveerror = Driveinit() |
| + | $include "Config_AVR-DOS.inc" ' Include AVR-DOS Configuration and library |
| + | |
| + | |
| + | Print #2 , "Init File System ... " ; |
| + | Btemp1 = Initfilesystem(1) ' Reads the Master boot record and the partition boot record (Sector) from the flash card and initializes the file system |
| + | '1 = Partitionnumber |
| + | If Btemp1 <> 0 Then |
| + | Print #2 , "Error: " ; Btemp1 ; " at Init file system" |
| + | Else |
| + | Print #2 , " OK --> Btemp1= " ; Btemp1 ; " / Gbdriveerror = " ; Gbdriveerror |
| + | Print #2 , "Filesystem = " ; Gbfilesystem |
| + | Print #2 , "FAT Start Sector: " ; Glfatfirstsector |
| + | Print #2 , "Root Start Sector: " ; Glrootfirstsector |
| + | Print #2 , "Data First Sector: " ; Gldatafirstsector |
| + | Print #2 , "Max. Cluster Nummber: " ; Glmaxclusternumber |
| + | Print #2 , "Sectors per Cluster: " ; Gbsectorspercluster |
| + | Print #2 , "Root Entries: " ; Gwrootentries |
| + | Print #2 , "Sectors per FAT: " ; Glsectorsperfat |
| + | Print #2 , "Number of FATs: " ; Gbnumberoffats |
| + | End If |
| + | |
| + | Print #2 , |
| + | Print #2 , |
| + | |
| + | '------------------------------------------------------------------------- |
| + | ' Write Text to file |
| + | File_handle = Freefile() ' get a file handle |
| + | File_name = "My_file.txt" |
| + | Open File_name For Output As #file_handle ' open file for output with file_handle |
| + | ' If the file exist already, the file will be overwritten ! |
| + | Print #file_handle , "This is my 1 first Text to File with XMEGA !" |
| + | Close #file_handle |
| + | |
| + | Print #2 , "Write to file done !" |
| + | |
| + | '------------------------------------------------------------------------- |
| + | 'Now we want to read back the text we wrote to file and print it over Serial Interface |
| + | File_handle = Freefile() |
| + | Open "My_file.txt" For Input As #file_handle ' we can use a constant for the file too |
| + | Print #2 , "File length = " ; Lof(#file_handle) |
| + | Line Input #file_handle , Input_string ' read a line |
| + | Print #2 , Input_string 'print the line |
| + | Close #file_handle |
| + | |
| + | |
| + | |
| + | |
| + | 'WRITE TO FILE |
| + | Print #2 , "write to file" |
| + | File_name = "Test.txt" |
| + | Input_string = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" |
| + | |
| + | |
| + | Open File_name For Output As #10 |
| + | |
| + | While X < 10000 '10000 * 102 Byte / 100 = 10200 Byte |
| + | Print #10 , Input_string |
| + | X = X + 100 |
| + | Wend |
| + | |
| + | Close #10 |
| + | |
| + | |
| + | X = Filelen(file_name) |
| + | Print #2 , "Total bytes written: " ; X |
| + | |
| + | |
| + | |
| + | 'READ FROM FILE |
| + | |
| + | Open File_name For Input As #10 |
| + | While Eof(#10) = 0 |
| + | Line Input #10 , Output_string ' read a line |
| + | If Input_string <> Output_string Then |
| + | Print #2 , "Buffer Error! near byte: " ; X ; " " ; "[" ; Output_string ; "]" |
| + | Waitms 2000 |
| + | End If |
| + | Wend |
| + | Close #10 |
| + | |
| + | |
| + | Print #2 , "Write and Readback test done !" |
| + | |
| + | |
| + | |
| + | '------------------------------------------------------------------------- |
| + | 'Print the file name which was created before |
| + | Print #2 , "Dir function demo" |
| + | Input_string = Dir( "*.*") |
| + | 'The first call to the DIR() function must contain a file mask The * means everything. |
| + | ' Print File Names |
| + | While Len(input_string) > 0 ' if there was a file found |
| + | Print #2 , Input_string ; " " ; Filedate() ; " " ; Filetime() ; " " ; Filelen() |
| + | ' print file , the date the fime was created/changed , the time and the size of the file |
| + | Input_string = Dir() ' get next |
| + | Wend |
| + | |
| + | '------------------------------------------------------------------------- |
| + | |
| + | Print #2 , |
| + | Print #2 , "Diskfree = " ; Diskfree() |
| + | Print #2 , "Disksize = " ; Disksize() |
| + | |
| + | End If 'If Gbdriveerror = 0 Then |
| + | |
| + | |
| + | End 'end program |
| | | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Filename: XMEGA_AVR-DOS_SDHC.BAS</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Library needed: MMCSD_HC.LIB --> Place MMCSD_HC.LIB in the LIB-Path of BASCOM-AVR installation</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' MMCSD_HC.LIB will be called from config_MMCSD_HC.inc</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' AVR-DOS.Lbx</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Include file: config_MMCSD_HC.inc (will be called from XMEGA_AVR-DOS_SDHC.BAS)</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Used ATXMEGA: ATXMEGA128A1</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Used SPI Port: Port D (you can also use Software SPI)</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' File Structure:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' +-------------------------------------------------+</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' | XMEGA_AVR-DOS_SDHC.BAS | Main</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' +-------------------------------------------------+</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' | |</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' +--------------------+ +----------------------+</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' | config_MMCSD_HC.inc| | Config_AVR-DOS.inc | Include Files</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' +--------------------+ +----------------------+</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' | |</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' +--------------------+ +----------------------+</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' | MMCSD_HC.LIB | | AVR-DOS.Lbx | Libraries</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' +--------------------+ +----------------------+</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Terminal output of following example (with hardware SPI over Port.D):</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Used SD-Card: 4GByte SDHC Card</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'(</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">---Example for using a SDHC-Card with AVR-DOS and XMEGA---</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Starting... SDHC with ATXMEGA....</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">SD Card Type = SDHC Spec. 2.0 or later</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Init File System ... OK --> Btemp1= 0 / Gbdriveerror = 0</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Filesystem = 6</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">FAT Start Sector: 8196</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Root Start Sector: 8688</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Data First Sector: 8720</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Max. Cluster Nummber: 62794</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Sectors per Cluster: 128</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Root Entries: 512</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Sectors per FAT: 246</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Number of FATs: 2</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Write to file done !</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">File length = 46</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">This is my 1 first Text to File with XMEGA !</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">write to file</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Total bytes written: 10200</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Write and Readback test done !</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Dir function demo</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">LOGGER.TXT 01\01\01 01:00:00 3120</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">MY_FILE.TXT 01\01\01 01:00:00 46</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">TEST.TXT 01\01\01 01:00:00 10200</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Diskfree = 4018560</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">Disksize = 4018752</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">')</span>
| + | </source> |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span>
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"xm128a1def.dat"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 32000000 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'32MHz</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 128</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 128</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 128</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> Osc </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Disabled </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> 32mhzosc </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Enabled </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'32MHz</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> Sysclock </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 32mhz </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'32Mhz</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Priority</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Static </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Vector </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Application </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Lo </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Enabled </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'config interrupts</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Interrupts</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'=====[ Serial Interface to PC = COM5 ]========================================</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> Com5 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 57600 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Mode</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Asynchroneous </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Parity </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> None </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Stopbits </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Databits </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 8</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"COM5:"</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Binary</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Waitms</span><span style="font-size: 8pt; font-family: Courier;"> 1</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"---Example for using a SDHC-Card with AVR-DOS and XMEGA---"</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'=====[ Global Vars ]==========================================================</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Btemp1 </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Needed for Fat Drivers</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">String</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">*</span><span style="font-size: 8pt; font-family: Courier;"> 100</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Output_string </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">String</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">*</span><span style="font-size: 8pt; font-family: Courier;"> 100</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> File_handle </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">String</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">*</span><span style="font-size: 8pt; font-family: Courier;"> 14</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> X </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Long</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Starting... SDHC with ATXMEGA...."</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'------------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'=====[ Includes ]============================================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$include</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"config_MMCSD_HC.inc"</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"SD Card Type = "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Select</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Case</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_cardtype</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Case</span><span style="font-size: 8pt; font-family: Courier;"> 0 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"can't init the Card"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Case</span><span style="font-size: 8pt; font-family: Courier;"> 1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"MMC"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Case</span><span style="font-size: 8pt; font-family: Courier;"> 2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"SDSC Spec. 1.x "</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Case</span><span style="font-size: 8pt; font-family: Courier;"> 4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"SDSC Spec. 2.0 or later"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Case</span><span style="font-size: 8pt; font-family: Courier;"> 12 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"SDHC Spec. 2.0 or later"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Select</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-size: 8pt; font-family: Courier;"> Gbdriveerror </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 0 </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Then</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'from.... Gbdriveerror = Driveinit()</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$include</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Config_AVR-DOS.inc"</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Include AVR-DOS Configuration and library</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Init File System ... "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><br/><span style="font-size: 8pt; font-family: Courier;"> Btemp1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Initfilesystem</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">1</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Reads the Master boot record and the partition boot record (Sector) from the flash card and initializes the file system</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'1 = Partitionnumber</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-size: 8pt; font-family: Courier;"> Btemp1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);"><></span><span style="font-size: 8pt; font-family: Courier;"> 0 </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Then</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Error: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Btemp1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">" at Init file system"</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Else</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">" OK --> Btemp1= "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Btemp1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">" / Gbdriveerror = "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Gbdriveerror</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Filesystem = "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Gbfilesystem</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"FAT Start Sector: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Glfatfirstsector</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Root Start Sector: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Glrootfirstsector</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Data First Sector: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Gldatafirstsector</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Max. Cluster Nummber: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Glmaxclusternumber</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Sectors per Cluster: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Gbsectorspercluster</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Root Entries: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Gwrootentries</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Sectors per FAT: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Glsectorsperfat</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Number of FATs: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Gbnumberoffats</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">If</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Write Text to file</span><br/><span style="font-size: 8pt; font-family: Courier;"> File_handle </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Freefile</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' get a file handle</span><br/><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"My_file.txt"</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">file_handle </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' open file for output with file_handle</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' If the file exist already, the file will be overwritten !</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">file_handle </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"This is my 1 first Text to File with XMEGA !"</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">file_handle</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Write to file done !"</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Now we want to read back the text we wrote to file and print it over Serial Interface</span><br/><span style="font-size: 8pt; font-family: Courier;"> File_handle </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Freefile</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"My_file.txt"</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">file_handle </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' we can use a constant for the file too</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"File length = "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Lof</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(#</span><span style="font-size: 8pt; font-family: Courier;">file_handle</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Line</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">file_handle </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' read a line</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'print the line</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">file_handle</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'WRITE TO FILE</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"write to file"</span><br/><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Test.txt"</span><br/><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">10</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">While</span><span style="font-size: 8pt; font-family: Courier;"> X </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);"><</span><span style="font-size: 8pt; font-family: Courier;"> 10000 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'10000 * 102 Byte / 100 = 10200 Byte</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">10 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Input_string</span><br/><span style="font-size: 8pt; font-family: Courier;"> X </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> X </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">+</span><span style="font-size: 8pt; font-family: Courier;"> 100</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Wend</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">10</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> X </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Filelen</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">file_name</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Total bytes written: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> X</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'READ FROM FILE</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> File_name </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">10</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">While</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Eof</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(#</span><span style="font-size: 8pt; font-family: Courier;">10</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 0</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Line</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">10 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Output_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' read a line</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);"><></span><span style="font-size: 8pt; font-family: Courier;"> Output_string </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Then</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Buffer Error! near byte: "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> X </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">" "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"["</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> Output_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"]"</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Waitms</span><span style="font-size: 8pt; font-family: Courier;"> 2000</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">If</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Wend</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">10</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Write and Readback test done !"</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Print the file name which was created before</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Dir function demo"</span><br/><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dir</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"*.*"</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'The first call to the DIR() function must contain a file mask The * means everything.</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Print File Names</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">While</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Len</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier;">input_string</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">></span><span style="font-size: 8pt; font-family: Courier;"> 0 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' if there was a file found</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">" "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Filedate</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">" "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Filetime</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">" "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Filelen</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' print file , the date the fime was created/changed , the time and the size of the file</span><br/><span style="font-size: 8pt; font-family: Courier;"> Input_string </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dir</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' get next</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Wend</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Diskfree = "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Diskfree</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"Disksize = "</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">;</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Disksize</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'If Gbdriveerror = 0 Then</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'end program</span>
| + | |
− | | + | |
− |
| + | |
− | | + | |
− |
| + | |
− | | + | |
− |
| + | |
− | | + | |
− |
| + | |
− | | + | |
− |
| + | |
| | | |
| = <span class="f_Header">Example 1: Following the </span><span class="f_Header" style="color: rgb(0, 0, 255);">Config_MMCSD_HC.INC</span><span class="f_Header"> which is included in the main example program</span> = | | = <span class="f_Header">Example 1: Following the </span><span class="f_Header" style="color: rgb(0, 0, 255);">Config_MMCSD_HC.INC</span><span class="f_Header"> which is included in the main example program</span> = |
| | | |
− | | + | <source lang="bascomavr"> |
| + | $nocompile |
| + | |
| + | '------------------------------------------------------------------------------- |
| + | ' Config_MMCSD_HC.INC |
| + | ' Config File for MMC/SD/SDHC Flash Cards Driver |
| + | ' (c) 2003-2009 , MCS Electronics / Vögel Franz Josef |
| + | '------------------------------------------------------------------------------- |
| + | ' Place MMCSD_HC.LIB in the LIB-Path of BASCOM-AVR installation |
| + | ' |
| + | ' you can vary MMC_CS on HW-SPI and all pins on SOFT-SPI, check settings |
| + | ' |
| + | ' ========== Start of user definable range ===================================== |
| + | ' |
| + | ' Declare here you SPI-Mode |
| + | ' using HW-SPI: cMMC_Soft = 0 |
| + | Const Hardware_spi = 0 |
| + | ' not using HW_SPI: cMMC_Soft = 1 |
| + | Const Software_spi = 1 |
| + | |
| + | Const Cmmc_soft = Hardware_spi |
| + | |
| + | #if Cmmc_soft = 0 |
| + | |
| + | ' --------- Start of Section for HW-SPI ---------------------------------------- |
| + | |
| + | 'Port D of ATXMEGA is used in this example as SPI Interface to SD-Card |
| + | |
| + | Portd_pin6ctrl = &B00_011_000 'Enable Pullup for MISO Pin |
| + | |
| + | ' Define here Slave Slect (SS) Pin of Hardware SPI |
| + | Config Pind.4 = Output ' define here Pin for CS of MMC/SD Card |
| + | Mmc_cs Alias Portd.4 |
| + | Set Mmc_cs |
| + | |
| + | ' Define here Slave Slect (SS) Pin of Hardware SPI |
| + | Config Pind.4 = Output ' define here Pin of SPI SS |
| + | Spi_ss Alias Portd.4 |
| + | Set Spi_ss ' Set SPI-SS to Output and High por Proper work of |
| + | |
| + | |
| + | |
| + | 'FOR XMEGA DEVICES |
| + | #if _xmega = 1 |
| + | 'SPI Configuration for XMEGA |
| + | 'Used Library = $LIB "MMCSD_HC.LIB" |
| + | |
| + | |
| + | 'Portd.4 SS --> SD-Card Slave Select |
| + | 'Portd.5 MOSI --> SD-Card MISO |
| + | 'Portd.6 MISO --> SD-Card MOSI |
| + | 'Portd.7 CLK --> SD-Card Clock |
| + | |
| + | Config Spid = Hard , Master = Yes , Mode = 0 , Clockdiv = Clk2 , Data_order = Msb |
| + | Open "SPID" For Binary As #14 |
| + | Const _mmc_spi = Spid_ctrl |
| + | #else |
| + | |
| + | ' HW-SPI is configured to highest Speed |
| + | Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1 |
| + | ' Spsr = 1 ' Double speed on ATMega128 |
| + | Spiinit |
| + | #endif |
| + | |
| + | ' --------- End of Section for HW-SPI ------------------------------------------ |
| + | |
| + | #else ' Config here SPI pins, if not using HW SPI |
| + | |
| + | ' --------- Start of Section for Soft-SPI -------------------------------------- |
| + | |
| + | ' Chip Select Pin => Pin 1 of MMC/SD |
| + | Config Pind.4 = Output |
| + | Mmc_cs Alias Portd.4 |
| + | Set Mmc_cs |
| + | |
| + | ' MOSI - Pin => Pin 2 of MMC/SD |
| + | Config Pind.5 = Output |
| + | Set Pind.5 |
| + | Mmc_portmosi Alias Portd |
| + | Bmmc_mosi Alias 5 |
| + | |
| + | ' MISO - Pin => Pin 7 of MMC/SD |
| + | Config Pind.6 = Input |
| + | Mmc_portmiso Alias Pind |
| + | Bmmc_miso Alias 6 |
| + | |
| + | ' SCK - Pin => Pin 1 of MMC/SD |
| + | Config Pind.7 = Output |
| + | Set Pind.7 |
| + | Mmc_portsck Alias Portd |
| + | Bmmc_sck Alias 7 |
| + | |
| + | ' --------- End of Section for Soft-SPI ---------------------------------------- |
| + | |
| + | #endif |
| + | |
| + | ' ========== End of user definable range ======================================= |
| + | |
| + | |
| + | '==== Variables For Application ================================================ |
| + | Dim Mmcsd_cardtype As Byte ' Information about the type of the Card |
| + | ' 0 can't init the Card |
| + | ' 1 MMC |
| + | ' 2 SDSC Spec. 1.x |
| + | ' 4 SDSC Spec. 2.0 or later |
| + | ' 12 SDHC Spec. 2.0 or later |
| + | |
| + | Dim Gbdriveerror As Byte ' General Driver Error register |
| + | ' Values see Error-Codes |
| + | '=============================================================================== |
| + | |
| + | |
| + | |
| + | ' ==== Variables for Debug ===================================================== |
| + | ' You can remove remarks(') if you want check this variables in your application |
| + | Dim Gbdrivestatusreg As Byte ' Driver save here Card response |
| + | ' Dim gbDriveErrorReg as Byte at GbdriveStatusReg overlay ' |
| + | ' Dim gbDriveLastCommand as Byte ' Driver save here Last Command to Card |
| + | Dim Gbdrivedebug As Byte |
| + | ' Dim MMCSD_Try As Byte ' how often driver tried to initialized the card |
| + | '=============================================================================== |
| + | |
| + | |
| + | '==== Driver internal variables ================================================ |
| + | ' You can remove remarks(') if you want check this variables in your application |
| + | ' Dim _mmcsd_timer1 As Word |
| + | ' Dim _mmcsd_timer2 As Word |
| + | '=============================================================================== |
| + | |
| + | |
| + | |
| + | ' Error-Codes |
| + | Const Cperrdrivenotpresent = &HE0 |
| + | Const Cperrdrivenotsupported = &HE1 |
| + | Const Cperrdrivenotinitialized = &HE2 |
| + | |
| + | Const Cperrdrivecmdnotaccepted = &HE6 |
| + | Const Cperrdrivenodata = &HE7 |
| + | |
| + | Const Cperrdriveinit1 = &HE9 |
| + | Const Cperrdriveinit2 = &HEA |
| + | Const Cperrdriveinit3 = &HEB |
| + | Const Cperrdriveinit4 = &HEC |
| + | Const Cperrdriveinit5 = &HED |
| + | Const Cperrdriveinit6 = &HEE |
| + | |
| + | Const Cperrdriveread1 = &HF1 |
| + | Const Cperrdriveread2 = &HF2 |
| + | |
| + | Const Cperrdrivewrite1 = &HF5 |
| + | Const Cperrdrivewrite2 = &HF6 |
| + | Const Cperrdrivewrite3 = &HF7 |
| + | Const Cperrdrivewrite4 = &HF8 |
| + | |
| + | |
| + | |
| + | $lib "MMCSD_HC.LIB" |
| + | $external _mmc |
| + | ' Init the Card |
| + | Gbdriveerror = Driveinit() |
| + | |
| + | |
| + | ' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetSize() |
| + | $external Mmcsd_getsize |
| + | Declare Function Mmcsd_getsize() As Long |
| + | |
| + | |
| + | ' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetCSD() |
| + | ' write result of function to an array of 16 Bytes |
| + | $external Mmcsd_getcsd |
| + | Declare Function Mmcsd_getcsd() As Byte |
| + | |
| + | |
| + | ' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetCID() |
| + | ' write result of function to an array of 16 Bytes |
| + | $external Mmcsd_getcid |
| + | Declare Function Mmcsd_getcid() As Byte |
| + | |
| + | |
| + | ' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetOCR() |
| + | ' write result of function to an array of 4 Bytes |
| + | $external Mmcsd_getocr |
| + | Declare Function Mmcsd_getocr() As Byte |
| + | |
| + | |
| + | ' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetSDStat |
| + | ' write result of function to an array of 64 Bytes |
| + | $external Sd_getsd_status |
| + | Declare Function Sd_getsd_status() As Byte |
| + | |
| + | ' check the usage of the above functions in the sample MMCSD_Analysis.bas |
| + | ' check also the MMC and SD Specification for the content of the registers CSD, CID, OCR and SDStat |
| + | |
| + | |
| | | |
− |
| + | </source> |
− | | + | |
− |
| + | |
− | | + | |
− |
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$nocompile</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Config_MMCSD_HC.INC</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Config File for MMC/SD/SDHC Flash Cards Driver</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' (c) 2003-2009 , MCS Electronics / Vögel Franz Josef</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'-------------------------------------------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Place MMCSD_HC.LIB in the LIB-Path of BASCOM-AVR installation</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' you can vary MMC_CS on HW-SPI and all pins on SOFT-SPI, check settings</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' ========== Start of user definable range =====================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Declare here you SPI-Mode</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' using HW-SPI: cMMC_Soft = 0</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Hardware_spi </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 0</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' not using HW_SPI: cMMC_Soft = 1</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Software_spi </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cmmc_soft </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Hardware_spi</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">if</span><span style="font-size: 8pt; font-family: Courier;"> Cmmc_soft </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 0</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' --------- Start of Section for HW-SPI ----------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Port D of ATXMEGA is used in this example as SPI Interface to SD-Card</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> Portd_pin6ctrl </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">B00_011_000 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Enable Pullup for MISO Pin</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Define here Slave Slect (SS) Pin of Hardware SPI</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' define here Pin for CS of MMC/SD Card</span><br/><span style="font-size: 8pt; font-family: Courier;"> Mmc_cs </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portd</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> Mmc_cs</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Define here Slave Slect (SS) Pin of Hardware SPI</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' define here Pin of SPI SS</span><br/><span style="font-size: 8pt; font-family: Courier;"> Spi_ss </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portd</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> Spi_ss </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Set SPI-SS to Output and High por Proper work of</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'FOR XMEGA DEVICES</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">if</span><span style="font-size: 8pt; font-family: Courier;"> _xmega </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'SPI Configuration for XMEGA</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Used Library = $LIB "MMCSD_HC.LIB"</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Portd.4 SS --> SD-Card Slave Select</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Portd.5 MOSI --> SD-Card MISO</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Portd.6 MISO --> SD-Card MOSI</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Portd.7 CLK --> SD-Card Clock</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> Spid </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Hard </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Master </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Yes </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Mode</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 0 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Clockdiv </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Clk2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Data_order </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Msb</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"SPID"</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Binary</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier;">14</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> _mmc_spi </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Spid_ctrl</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">else</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' HW-SPI is configured to highest Speed</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> Spi </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Hard </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Interrupt </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Data</span><span style="font-size: 8pt; font-family: Courier;"> Order </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Msb </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Master </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> Yes </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Polarity </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">High</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Phase </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Clockrate </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> Noss </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Spsr = 1 ' Double speed on ATMega128</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Spiinit</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">endif</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' --------- End of Section for HW-SPI ------------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">else</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Config here SPI pins, if not using HW SPI</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' --------- Start of Section for Soft-SPI --------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Chip Select Pin => Pin 1 of MMC/SD</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Output</span><br/><span style="font-size: 8pt; font-family: Courier;"> Mmc_cs </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portd</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> Mmc_cs</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' MOSI - Pin => Pin 2 of MMC/SD</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">5 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Output</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">5</span><br/><span style="font-size: 8pt; font-family: Courier;"> Mmc_portmosi </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portd</span><br/><span style="font-size: 8pt; font-family: Courier;"> Bmmc_mosi </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> 5</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' MISO - Pin => Pin 7 of MMC/SD</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">6 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-size: 8pt; font-family: Courier;"> Mmc_portmiso </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><br/><span style="font-size: 8pt; font-family: Courier;"> Bmmc_miso </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> 6</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' SCK - Pin => Pin 1 of MMC/SD</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">7 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Output</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Pind</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">7</span><br/><span style="font-size: 8pt; font-family: Courier;"> Mmc_portsck </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portd</span><br/><span style="font-size: 8pt; font-family: Courier;"> Bmmc_sck </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Alias</span><span style="font-size: 8pt; font-family: Courier;"> 7</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' --------- End of Section for Soft-SPI ----------------------------------------</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">#</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">endif</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' ========== End of user definable range =======================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'==== Variables For Application ================================================</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_cardtype </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Information about the type of the Card</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 0 can't init the Card</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 1 MMC</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 2 SDSC Spec. 1.x</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 4 SDSC Spec. 2.0 or later</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 12 SDHC Spec. 2.0 or later</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Gbdriveerror </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' General Driver Error register</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Values see Error-Codes</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'===============================================================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' ==== Variables for Debug =====================================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' You can remove remarks(') if you want check this variables in your application</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Gbdrivestatusreg </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Driver save here Card response</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Dim gbDriveErrorReg as Byte at GbdriveStatusReg overlay '</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Dim gbDriveLastCommand as Byte ' Driver save here Last Command to Card</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-size: 8pt; font-family: Courier;"> Gbdrivedebug </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Dim MMCSD_Try As Byte ' how often driver tried to initialized the card</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'===============================================================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'==== Driver internal variables ================================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' You can remove remarks(') if you want check this variables in your application</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Dim _mmcsd_timer1 As Word</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Dim _mmcsd_timer2 As Word</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'===============================================================================</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Error-Codes</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivenotpresent </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HE0</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivenotsupported </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HE1</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivenotinitialized </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HE2</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivecmdnotaccepted </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HE6</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivenodata </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HE7</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveinit1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HE9</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveinit2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HEA</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveinit3 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HEB</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveinit4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HEC</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveinit5 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HED</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveinit6 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HEE</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveread1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HF1</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdriveread2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HF2</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivewrite1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HF5</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivewrite2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HF6</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivewrite3 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HF7</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Const</span><span style="font-size: 8pt; font-family: Courier;"> Cperrdrivewrite4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">&</span><span style="font-size: 8pt; font-family: Courier;">HF8</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$lib</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"MMCSD_HC.LIB"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$external</span><span style="font-size: 8pt; font-family: Courier;"> _mmc</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Init the Card</span><br/><span style="font-size: 8pt; font-family: Courier;">Gbdriveerror </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Driveinit</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetSize()</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$external</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getsize</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Declare</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Function</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getsize</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Long</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetCSD()</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' write result of function to an array of 16 Bytes</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$external</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getcsd</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Declare</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Function</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getcsd</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetCID()</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' write result of function to an array of 16 Bytes</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$external</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getcid</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Declare</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Function</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getcid</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetOCR()</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' write result of function to an array of 4 Bytes</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$external</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getocr</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Declare</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Function</span><span style="font-size: 8pt; font-family: Courier;"> Mmcsd_getocr</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' you can remark/remove following two Code-lines, if you dont't use MMCSD_GetSDStat</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' write result of function to an array of 64 Bytes</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$external</span><span style="font-size: 8pt; font-family: Courier;"> Sd_getsd_status</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Declare</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Function</span><span style="font-size: 8pt; font-family: Courier;"> Sd_getsd_status</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">()</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' check the usage of the above functions in the sample MMCSD_Analysis.bas</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' check also the MMC and SD Specification for the content of the registers CSD, CID, OCR and SDStat</span>
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span>
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span>
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span>
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span>
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span>
| + | |
− | | + | |
− | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span>
| + | |
| | | |
| = <span class="f_Header">Example 1: Following the </span><span class="f_Header" style="color: rgb(0, 0, 255);">Config_AVR-DOS.inc</span><span class="f_Header"> which is included in the main example program</span> = | | = <span class="f_Header">Example 1: Following the </span><span class="f_Header" style="color: rgb(0, 0, 255);">Config_AVR-DOS.inc</span><span class="f_Header"> which is included in the main example program</span> = |
AVR-DOS is a Disk Operating System (DOS) for Atmel AVR microcontroller.
The AVR-DOS file system is written by Josef Franz Vögel. He can be contacted via the BASCOM forum.
Josef has put a lot of effort in writing and especially testing the routines.
SD-card is a further development of the former MMC (Multi Media Card).
FAT = File Allocation Table and is the name of the file system architecture (FAT16 means 16-Bit version of FAT).
A SD or SDHC card is working at 2.7V ... 3.6V so for ATMEGA running at 5V you need a voltage converter or voltage divider. ATXMEGA are running at 2.7V ... 3.6V anyway so you can connect the sd-card direct to the ATXMEGA pin's.
Everything is written in Assembler to ensure a fast and compact code.
The intention in developing the DOS – file system was to keep close to the equivalent VB functions.
When you develop a commercial product with AVR-DOS you need the company license. The ASM source is shipped with both licenses.
1. Driver interface Library (select one of the following):
2. After calling the Driver interface library you need check the Error Byte which is Gbdriveerror and which is output of the function DRIVEINIT(). If the output is 0 (no error) you can include the AVR-DOS configuration file. Otherwise you should output the error number.
When you want change (ejecting from the card socket) the SD-card (during the AVR is running other code than AVR-DOS) you need to call DRIVEINIT() and INITFILESYSTEM(1) again in order to reset the AVR-Hardware (PORTs, PINs) attached to the Drive,reset the Drive again and initialize the file system again.
With the above configuration and with the filename there is approximately 500 byte SRAM left in an ATMEGA32 for other tasks. Or in other words AVR-DOS needs at least 1500 Byte SRAM in this case. To get detailed values compile your AVR-DOS application and open the Bascom-AVR compiler Report (CTRL+W) then you see the value with Space left : 508 Bytes (then you have 508 Bytes left for other tasks).
TTo get started there are Examples in the ...BASCOM-AVR\SAMPLES\avrdos folder.
The MMC.lib is for SD-Cards (Standard SD-Cards usually up to 2Gbyte and not for SDHC cards)
1. General File System information (need 35 Byte in SRAM)
2. Directory (need 559 Byte in SRAM)
3. FAT (need 517 Byte in SRAM)
4. File handling
Depending on the used SD-card (or microSD) socket you can also detect if the card is inserted or ejected (for this you need an additional pin on the micro).
In some cases it is best practise to spend another pin able to switch on and off the power to the SD-card socket (e.g. over a transistor or FET). In this case you can cycle power from the AVR when the sd-card controller hangs.
It is also best practise in some cases when you open a file for append, write the data to it and close it right after this so there is no open file where data could be corrupted by an undefined external event.
This example uses: $include "Config_MMCSD_HC.bas" which calls following Libary: $lib "MMCSD_HC.LIB"
This example is written for ATMEGA but is also working for ATXMEGA devices.