|
© MCS Electronics, 1995-2007 |
$baud = 19200 |
' use baud rate |
$hwstack = 32 |
' default use 32 |
for the hardware stack |
' default use 10 |
$swstack = 10 |
for the SW stack |
' default use 40 |
$framesize = 40 |
for the frame space |
|
Dim A As Byte |
|
A = 1 |
'assign a var |
Do |
'begin a do..loop |
Print A |
'print var |
Incr A |
'increase by one |
Loop Until A = 10 |
'do until a=10 |
End |
|
'You can write a never-ending loop with the following code
Do
'Your code goes here
Loop
DriveCheck
Action
Checks the Drive, if it is ready for use
Syntax
bErrorCode = DRIVECHECK()
Remarks
bErrorCode |
A Byte Variable, which is assigned with the return value of the |
|
function |
|
|
This function checks the drive, if it is ready for use (for example, whether a compact flash card is inserted). The functions returns 0 if the drive can be used, otherwise an error code is returned. For Error code see section Error codes.
See also
DriveReset , DriveInit , DriveGetIdentity , DriveWriteSector , DriveReadSector
ASM
Calls |
_DriveCheck |
|
Input |
none |
|
Output |
r25: Errorcode |
C-Flag: Set on Error |
|
|
|
Partial Example
Dim bError as Byte
© MCS Electronics, 1995-2007
bError = DriveCheck()
DriveGetIdentity
Action
Returns the Parameter information from the Card/Drive
Syntax
bErrorCode = DRIVEGETIDENTIFY(wSRAMPointer)
Remarks
BErrorCode |
A Byte Variable, which is assigned with the errorcode of the function |
wSRAMPointe |
A Word Variable, which contains the SRAM address (pointer) , to which |
r |
the information of the Drive should be written |
|
|
The Identify Drive Function returns the parameter information (512 Bytes) from the CompactFlash Memory Card/Drive and writes it to SRAM starting at the address, to which the content of the variable wSRAMPointer is pointing. This information are for example number of sectors of the card, serial number and so on. Refer to the Card/Drive manual for further information. The functions returns 0 if no error occurred. For Error code see section Error codes.
Note: For meaning of wSRAMPointer see Note in DriveReadSector
See also
DriveCheck, DriveReset , DriveInit , DriveWriteSector , DriveReadSector
ASM
Calls |
_DriveGetIdentity |
|
Input |
|
Z: SRAM-Address of buffer |
|
|
*) |
Output |
r25: Errorcode |
C-Flag: Set on Error |
|
|
|
*) Please note: This is not the address of wSRAMPointer, it is its content, which is the starting-address of the buffer.
Partial Example
Dim bError as Byte
Dim aBuffer(512) as Byte' Hold Sector to and from CF-Card
Dim wSRAMPointer as Word' Address-Pointer for write
'give Address of first Byte of the 512 Byte Buffer to Word-Variable wSRAMPointer =VarPtr(aBuffer(1))
'Now read the parameter Information from CF-Card
bError = DriveGetIdentity( wSRAMPointer)
© MCS Electronics, 1995-2007
DriveInit
Action
Sets the AVR-Hardware (PORTs, PINs) attached to the Drive and resets the Drive.
Syntax
bErrorCode = DRIVEINIT()
Remarks
BErrorCode |
A Byte Variable, which is assigned with the errorcode of the function |
|
|
Set the Ports and Pins attaching the Drive for Input/Output and give initial values to the output-pins. After that the Drive is reset. Which action is done in this function depends of the drive and its kind of connection to the AVR. The functions returns 0 if no error occured. For Errorcode see section Errorcodes.
See also
DriveCheck, DriveReset , DriveGetIdentity , DriveWriteSector , DriveReadSector
ASM
Calls |
_DriveInit |
|
Input |
none |
|
Output |
r25: Errorcode |
C-Flag: Set on Error |
|
|
|
Partial Example
Dim bError as Byte
bError = DriveInit()
DriveReset
Action
Resets the Drive.
Syntax
bErrorCode = DRIVERESET()
Remarks
BErrorCode A Byte Variable, which is assigned with the error code of the function
This function resets the drive and brings it to an initial state. The functions returns 0 if no error occurred. For Error code see section Error codes.
© MCS Electronics, 1995-2007
See also
DriveCheck, DriveInit , DriveGetIdentity , DriveWriteSector , DriveReadSector
ASM
Calls |
_DriveReset |
|
Input |
none |
|
Output |
r25: Errorcode |
C-Flag: Set on Error |
|
|
|
Partial Example
Dim bError as Byte
bError = DriveReset()
DriveReadSector
Action
Read a Sector (512 Bytes) from the (Compact Flashcard-) Drive
Syntax
bErrorCode = DRIVEREADSECTOR(wSRAMPointer, lSectorNumber)
Remarks
bErrorCode |
A Byte Variable, which is assigned with the error code of the function |
wSRAMPointer |
A Word Variable, which contains the SRAM address (pointer) , to which |
|
the Sector from the Drive should be written |
lSectorNumber |
A Long Variable, which give the sector number on the drive be |
|
transfer. |
|
|
Reads a Sector (512 Bytes) from the Drive and write it to SRAM starting at the address, to which the content of the variable wSRAMPointer is pointing. The functions returns 0 if no error occurred. For Error code see section Error codes.
Note: wSRAMPointer is not the variable, to which the content of the desired drive-sector should be written, it is the Word-Variable/Value which contains the SRAM address of the range, to which 512 Bytes should be written from the Drive. This gives you the flexibility to read and write every SRAM-Range to and from the drive, even it is not declared as variable. If you know the SRAM-Address (from the compiler report) of a buffer you can pass this value directly, otherwise you can get the address with the BASCOM-function VARPTR (see example).
See also
DriveCheck, DriveReset , DriveInit , DriveGetIdentity , DriveWriteSector
ASM
page -470-