© MCS Electronics, 1995-2007
Input |
Z: SRAM-Address of buffer |
X: Address of Long-variable with |
|
*) |
sectornumber |
Output |
r25: Errorcode |
C-Flag: Set on Error |
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
Dim lSectorNumber as Long' Sector Number
'give Address of first Byte of the 512 Byte Buffer to Word-Variable wSRAMPointer =VarPtr(aBuffer(1))
'Set Sectornumber, sector 32 normally holds the Boot record sector of first partition lSectorNumber = 32
'Now read in sector 32 from CF-Card
bError = DriveReadSector( wSRAMPointer , lSectorNumber) ' Now Sector number 32 is in Byte-Array bBuffer
DriveWriteSector
Action
Write a Sector (512 Bytes) to the (Compact Flashcard-) Drive
Syntax
bErrorCode = DRIVEWRITESECTOR(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), from which the Sector to the Drive should be written
lSectorNumbe A Long Variable, which give the sector number on the drive to transfer. r
Writes a Sector (512 Bytes) from SRAM starting at the address, to which the content of the variable wSRAMPointer is pointing to the Drive to sector number lSectornumber. The functions returns 0 if no error occurred. For Error code see section Error codes.
For the meaning of wSRAMPointer see Note in DriveReadSector
See also
DriveCheck, DriveReset , DriveInit , DriveGetIdentity , DriveReadSector
page -471-
© MCS Electronics, 1995-2007
ASM
Calls |
_DriveWriteSector |
|
Input |
Z: SRAM-Address of buffer |
X: Address of Long-variable with |
|
*) |
sectornumber |
Output |
r25: Errorcode |
C-Flag: Set on Error |
|
|
|
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 read
Dim lSectorNumber as Long' Sector Number
'give Address of first Byte of the 512 Byte Buffer to Word-Variable wSRAMPointer =VarPtr(aBuffer(1))
'Set Sectornumber
lSectorNumber = 3
' Now Write in sector 3 from CF-Card
bError = DriveWriteSector( wSRAMPointer , lSectorNumber)
DTMFOUT
Action
Sends a DTMF tone to the compare1 output pin of timer 1.
Syntax
DTMFOUT number, duration
DTMFOUT string , duration
Remarks
Number |
A variable or numeric constant that is equivalent with the number of your |
|
phone keypad. |
Duration |
Time in mS the tone will be generated. |
string |
A string variable that holds the digits to be dialed. |
|
|
The DTMFOUT statement is based on an Atmel application note (314).
It uses TIMER1 to generate the dual tones. As a consequence, timer1 can not be used in interrupt mode by your application. You may use it for other tasks.
© MCS Electronics, 1995-2007
Since the TIMER1 is used in interrupt mode you must enable global interrupts with the statement ENABLE INTERRUPTS. The compiler could do this automatic but when you use other interrupts as well it makes more sense that you enable them at the point where you want them to be enabled.
The working range is from 4 MHz to 10 MHz system clock(xtal).
The DTMF output is available on the TIMER1 OCA1 pin. For a 2313 this is PORTB.3.
Take precautions when connecting the output to your telephone line.
Ring voltage can be dangerous!
System Resources used
TIMER1 in interrupt mode
See also
NONE
ASM
The following routine is called from mcs.lib : _DTMFOUT
R16 holds the number of the tone to generate, R24-R25 hold the duration time in mS. Uses R9,R10,R16-R23
The DTMF table is remarked in the source and shown for completeness, it is generated by the compiler however with taking the used crystal in consideration.
Example
'----------------------------------------------------------------------------- |
|
------------ |
: dtmfout.bas |
'name |
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: demonstrates DTMFOUT statement based on AN 314 |
from Atmel |
: Mega48 |
'micro |
'suited for demo |
: yes |
'commercial addon needed |
: no |
'----------------------------------------------------------------------------- |
|
------------ |
|
$regfile = "m48def.dat" |
' specify the used |
micro |
' used crystal |
$crystal = 8000000 |
frequency |
' use baud rate |
$baud = 19200 |
$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 |
|
|
page -473- |
© MCS Electronics, 1995-2007
'since the DTMFOUT statement uses the TIMER1 interrupt you must enable 'global interrupts
'This is not done by the compiler in case you have more ISRs
Enable Interrupts
'the first sample does dtmfout in a loop
Dim Btmp As Byte , Sdtmf As String * 10
Sdtmf = "12345678" |
|
' number to dial |
Do |
|
|
Dtmfout Sdtmf , 50 |
' lets dial a |
number |
^ duration is 50 mS for each digit |
|
' |
' wait for one |
Waitms 1000 |
|
second |
|
|
'As an alternative you can send single digits
'there are 16 dtmf tones
For Btmp = 0 To 15 |
' dtmf out on |
|
Dtmfout Btmp , 50 |
PORTB.3 for the 2313 |
for 500 mS |
|
'output is on the OC1A output pin |
|
Waitms 500 |
|
' wait 500 msec |
Next |
|
|
|
|
Loop |
|
|
|
|
End |
|
|
|
|
'the keypad of most phones looks like this : |
'1 |
2 |
3 |
optional are A |
'4 |
5 |
6 |
|
|
B |
'7 |
8 |
9 |
|
|
C |
'* |
0 |
# |
|
|
D |
'the DTMFOUT translates a numeric value from 0-15 into : |
' numeric value |
phone key |
' |
0 |
|
|
|
0 |
' |
1 |
|
|
|
1 |
' |
2 |
|
|
|
2 |
' |
3 |
|
|
|
3 |
' etc. |
|
|
|
9 |
' |
9 |
|
|
|
' |
10 |
|
|
|
* |
' |
11 |
|
|
|
# |
' |
12 |
|
|
|
A |
' |
13 |
|
|
|
B |
' |
14 |
|
|
|
C |
' |
15 |
|
|
|
D |
ECHO
Action
Turns the ECHO on or off while asking for serial INPUT.
Syntax
© MCS Electronics, 1995-2007
ECHO value
Remarks
Value |
ON to enable ECHO and OFF to disable ECHO. |
|
|
When you use INPUT to retrieve values for variables, all info you type can be echoed back. In this case you will see each character you enter. When ECHO is OFF, you will not see the characters you enter.
In versions 1.11.6.2 and earlier the ECHO options were controlled by an additional parameter on the INPUT statement line like : INPUT "Hello " , var NOECHO
This would suppress the ECHO of the typed data. The new syntax works by setting ECHO ON and OFF. For backwards compatibility, using NOECHO on the INPUT statement line will also work. In effect it will turn echo off and on automatic.
By default, ECHO is always ON.
See also
INPUT
ASM
The called routines from mcs.lib are _ECHO_ON and _ECHO_OFF
The following ASM is generated when you turn ECHO OFF.
Rcall Echo_Off
This will set bit 3 in R6 that holds the ECHO state.
When you turn the echo ON the following code will be generated
Rcall Echo_On
Example
'----------------------------------------------------------------------------- |
|
------------ |
: input.bas |
'name |
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: demo: INPUT, INPUTHEX |
'micro |
: Mega48 |
'suited for demo |
: yes |
'commercial addon needed |
: no |
'-----------------------------------------------------------------------------
------------
$regfile = "m48def.dat" |
' specify the used |
micro |
' used crystal |
$crystal = 4000000 |
frequency |
' use baud rate |
$baud = 19200 |
$hwstack = 32 |
' default use 32 |
for the hardware stack |
' default use 10 |
$swstack = 10 |
for the SW stack |
' default use 40 |
$framesize = 40 |