© MCS Electronics, 1995-2007
Syntax
CONFIG XRAM = mode [ , WaitstateLS=wls , WaitStateHS=whs ]
Remarks
Mode |
The memory mode. This is either enabled or disabled. By default, external |
|
memory access is disabled. |
Wls |
When external memory access is enabled, some chips allow you to set a |
|
wait state. The number of modes depend on the chip. A modern chip such |
|
as the Mega8515 has 4 modes : |
|
0 |
- no wait states |
|
1 |
- 1 cycle wait state during read/write |
|
2 |
- 2 cycle wait state during read/write |
|
3 |
- 2 cycle wait state during read/write and 1 before new address output |
|
WLS works on the lower sector. Provided that the chip supports this. |
Whs |
When external memory access is enabled, some chips allow you to set a |
|
wait state. The number of modes depend on the chip. A modern chip such |
|
as the Mega8515 has 4 modes : |
|
0 |
- no wait states |
|
1 |
- 1 cycle wait state during read/write |
|
2 |
- 2 cycle wait state during read/write |
|
3 |
- 2 cycle wait state during read/write and 1 before new address output |
|
WHS works on the high sector. Provided that the chip supports this. |
|
|
|
Wait states are needed in case you connect equipment to the bus, that is relatively slow. Especial older electronics/chips.
Some AVR chips also allow you to divide the memory map into sections. By default the total XRAM memory address is selected when you set a wait state.
The $XA directive should not be used anymore. It is the same as CONFIG XRAM=Enabled
See also
$XA , $WAITSTATE
ASM
NONE
Example
CONFIG XRAM = Enabled, WaitstateLS=1 , WaitstateHS=2
CONST
Action
Declares a symbolic constant.
Syntax
© MCS Electronics, 1995-2007
CONST symbol = numconst
CONST symbol = stringconst
CONST symbol = expression
Remarks
Symbol |
The name of the symbol. |
Numconst |
The numeric value to assign to the symbol. |
Stringconst |
The string to assign to the symbol |
Expression |
An expression that returns a value to assign the constant |
|
|
Assigned constants consume no program memory because they only serve as a reference to the compiler.
The compiler will replace all occurrences of the symbol with the assigned value.
You can use a constant to give a value a more meaningful name.
For example : variable = 1
const optHeaterOn = 1 variable = optHeaterOn
The source code is better to read when you assign a constant. Even better when the values change later, for example when HeaterOn becomes 2, you only need to replace 1 line of code.
See also
ALIAS
Example
'----------------------------------------------------------------------------- |
|
------------ |
: const.bas |
'name |
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: demo for constants |
'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 |
for the frame space |
|
'dimension some variables
Dim Z As String * 10 Dim B As Byte
'assign some constants
'constants dont use program memory
page -404-
|
© MCS Electronics, 1995-2007 |
|
Const S = "test" |
'declare a as a |
Const A = 5 |
constant |
|
Const |
B1 = &B1001 |
|
'or use an expression to assign a constant |
|
Const X =(b1 * 3) + 2 |
|
Const Ssingle = Sin(1) |
|
Print X |
|
Print Ssingle |
|
B = A |
|
|
'the same as b = 5 |
|
Z = S |
|
|
'the same as Z = "test" |
|
Print A |
|
Print B1 |
|
Print S |
|
'you can use constants with conditional compilation |
' note there is no |
#if A = 5 |
then |
|
|
Print "constant a is 5" |
|
#if S = "test" |
|
Print "nested example" |
' else is optional |
#else |
#endif |
|
#else |
|
|
#endif |
|
End
COS
Action
Returns the cosine of a single
Syntax
var = COS( single )
Remarks
Var |
A numeric variable that is assigned with cosine of variable single. |
Single |
The single variable to get the cosine of. |
|
|
All trig functions work with radians. Use deg2rad and rad2deg to convert between radians and angles.
See Also
RAD2DEG , DEG2RAD , ATN , SIN , TAN
© MCS Electronics, 1995-2007
Example
$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 |
|
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits |
= 8 , Clockpol = 0 |
|
Dim S As Single , X As Single |
' prints |
S = 0.5 : X = Tan(s) : Print X |
0.546302195 |
' prints |
S = 0.5 : X = Sin(s) : Print X |
0.479419108 |
' prints |
S = 0.5 : X = Cos(s) : Print X |
0.877588389 |
|
End |
|
COSH
Action
Returns the cosine hyperbole of a single
Syntax
var = COSH( single )
Remarks
Var |
A numeric variable that is assigned with cosine hyperbole of |
|
variable single. |
Single |
The single or double variable to get the cosine hyperbole of. |
|
|
All trig functions work with radians. Use deg2rad and rad2deg to convert between radians and angles.
See Also
RAD2DEG , DEG2RAD , ATN , COS , SIN , TANH , SINH
Example
Show sample