manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets
Table of Contents

Introduction

Specifications

Hardware

Flash Card

Connecting To the Wildcard Bus

Selecting the Wildcard Address

Installing the CF Card

CF Card Software Package User Guide and Glossary

How To Install the CF Software

Using the Driver Code with C

Using the Driver Code with Forth

CF Card Software

Categorized List of Functions and Constants

ATA Failure Codes

ATA Primitives

CF Card Information

Directory

File Access and Position Modes

File I/O

File Processing

File System Error Handling

Initialization

Overview of Glossary Notation

Using the File System Functions

Commonly Used Terms

String Parameters and the Use of THIS_PAGE

Access Privileges

Root Directory Only and File Name Restrictions

File Position Indicator

Error Handling

Real-Time Clock on the Host Computer Enables Time/Date Marking of Files 12

Initialization

Automatic Initialization and File Processing

Upgrade note for former Memory Interface Board (MIB) Users

How To Create and Use an AUTOEXEC.QED File

Compile a Program into Flash Memory

Create a Set of Image Files

Transfer the Image File Contents into Memory

Restrictions on Software Upgrades

Recovering from Buggy AUTOSTART.QED Files

Compact Flash Card Software Package Main Glossary

Upgrade Notice for Prior Users of the Memory Interface Board

Sample FILEDEMO.C File (pdf)

Sample FILEDEMO.4th File (pdf)

CF Wildcard Hardware Schematic

The Compact-Flash Wildcard and
CF Card Software Package User Guide

<< Previous | Next>>

C: int File_Set_Pos( int file_id, long offset )
4th: File_Set_Pos ( file_id\d.offset -- error ) Moves the file position indicator of the specified file to the specified positive 32-bit offset from the start of the file by calling File_Seek using the FROM_START mode. See File_Seek, File_Rewind, and File_Tell_Pos.

C: ulong File_Size( int file_id )
4th: File_Size ( file_id -- d.file_size )
Returns the size of the specified file as a 32-bit number.

C: long File_Tell_Pos( int file_id )
4th: File_Tell_Pos ( file_id -- d.offset )
Returns the current file position of the specified file as a 32-bit offset from the start of the file. The first byte in the file is at offset = 0, and the last byte in the file is at offset (filesize - 1). Returns -1 if the file is not open. See File_Seek and File_Set_Pos.

C: xaddr File_Time( int file_id )
4th: File_Time ( file_id -- xaddr )
Based on the information stored in the FAT directory entry of the specified file, decodes time and date and writes it to a structure associated with the file located in the file system heap. Returns the 32-bit extended base address of the structure. This low-level function is provided as a convenience; it is not used in most applications. The data is stored as follows:

Data Offset Type Min. Max.
Seconds 0 byte 0 59
Minutes 1 byte 0 59
Hours 2 byte 0 23
Date 3 byte 1 31
Month 4 byte 1 12
Year 5,6 int 2000 2099
The "offset" specifies where the parameter is stored, relative to the xaddr returned by this function. The "Min." and "Max." columns specify the allowed ranges for each data type. C programmers should note that the time information is stored in paged memory, so standard C structure notation does not work, and the paged memory access functions such as StoreChar(), FetchChar(), and CmoveMany() must be used to access the data.

C: long File_To_Memory( void* dest_addr, uint dest_page, ulong numbytes, int file_id )
4th: File_To_Memory ( dest_xaddr\d.numbytes\file_id -- d.numbtyes_read )
Reads from the specified open file to the specified destination in RAM or QED flash memory, and returns the number of bytes read as a 32-bit number. This is the fastest way to load the saved binary image of a compiled program from a CF card into memory (see the AUTOEXEC.QED example at the end of this document for an example of use). File_To_Memory reads numbytes characters starting at the current file position. If the specified destination region is not flash memory, this function simply calls File_Read to perform the data transfer. If the specified destination region is flash memory as described in the implementation details section below, then this function transfers the data into flash memory via the specified file's File_Contents RAM buffer (see the File_Contents glossary entry). The bytes are placed in memory starting at the specified dest_addr on the specified page. A standard procedure is for the calling program to test whether the returned number of bytes read equals the specified input parameter numbytes, and to infer that an error condition occurred if they are unequal. If an error occurs during the read operation, the error code is OR'd with any prior error condition, and the composite bitmapped error code can be retrieved by calling File_Error. An end of file condition can be separately tested for by calling the File_EOF function. See the glossary entries that start with "ERR_" for a complete list of error codes. Implementation details: If there was a prior call to the File_Ungetc function, the "ungot" character is moved to the destination in place of the first file character. To transfer an entire file, use the File_Size function to specify d.numbytes (but recall that C programmers can't call the File_Size function from within the parameter list of File_To_Memory; see the "Tips for C Programmers" section above). This function tests the specified dest_addr as well as the last address to be written; if either of these memory locations is in a known flash area, the flash transfer is used (note that RAM is still properly programmed by the flash transfer, but it takes longer). Otherwise, a RAM transfer is performed by File_Read. Known flash areas are on the QED Board page 7; page 0x0D; and pages 1 to 3 in the DOWNLOAD.MAP or pages 4 to 6 in the STANDARD.MAP.
Benchmark: Transfers from the ATA flash card to RAM take approximately 125 msec per Kbyte, and transfers from the ATA flash card to flash memory take approximately 420 msec per Kbyte. Transfers to flash disable interrupts for up to 25 msec per flash sector.

C: void File_To_Page ( uint page )
4th: File_To_Page ( page -- )
Looks for a file named PAGEpp.BIN, where pp is a hexadecimal representation of the specified page. If the file is found, opens it in read mode, invokes File_To_Memory to copy the file contents to the specified page, and closes the file. For example, if the specified page is 4, then PAGE04.BIN will be opened and its contents copied to page 4. See the glossary entries for File_To_Memory and Page_To_File. Before calling this function, the file system must have been initialized. The file must be a binary file containing exactly 32 kbytes; otherwise an error will be reported and no information will be copied. This function prints a string to the serial output reporting the result.
Output messages are:
    File_To_Page completed copy of PAGEpp.BIN
    File_To_Page couldn't open PAGEpp.BIN
    File_To_Page error: wrong file size at PAGEpp.BIN
    File_To_Page could not complete copy of PAGEpp.BIN
This routine is always callable by Process_File, even if the CF Card Forth headers have not been loaded onto the Mosaic controller.

<< Previous | Next>>


Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2006 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation