Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
BASCOM AVR, help reference (2007).PDF
Скачиваний:
281
Добавлен:
12.08.2013
Размер:
17.02 Mб
Скачать

© MCS Electronics, 1995-2007

An alternative for the buffer would be to setup a temp buffer and free it once finished. This gives more code overhead.

In older version of BASCOM the start of the frame was used for the buffer but that gave conflicts when variables were printed from an ISR.

See also

DBG

$DEFAULT

Action

Set the default for data types dimensioning to the specified type.

Syntax

$DEFAULT = var

Remarks

Var

SRAM, XRAM, ERAM

 

 

Each variable that is dimensioned will be stored into SRAM, the internal memory of the chip. You can override it by specifying the data type.

Dim B As XRAM Byte , will store the data into external memory.

When you want all your variables to be stored in XRAM for example, you can use the statement : $DEFAULT XRAM

Each Dim statement will place the variable in XRAM in that case.

To switch back to the default behavior, use $END$DEFAULT

See also

NONE

ASM

NONE

Example

$regfile = "m48def.dat" $crystal = 4000000 $baud = 19200

Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0

$default Xram

Dim A As Byte , B As Byte , C As Byte

'a,b and c will be stored into XRAM

$default Sram

Dim D As Byte

page -211-

© MCS Electronics, 1995-2007

'D will be stored in internal memory, SRAM

$EEPLEAVE

Action

Instructs the compiler not to recreate or erase the EEP file.

Syntax

$EEPLEAVE

Remarks

When you want to store data in the EEPROM, and you use an external tool to create the EEP file, you can use the $EEPLEAVE directive.

Normally the EEP file will be created or erased, but this directive will not touch any existing EEP file.

Otherwise you would erase an existing EEP file, created with another tool.

See also

$EEPROMHEX

Example

NONE

$EEPROM

Action

Instruct the compiler to store the data in the DATA lines following the $DATA directive in an EEP file.

Syntax

$EEPROM

Remarks

The AVR has built-in EEPROM. With the WRITEEEPROM and READEEPROM statements, you can write to and read from the EEPROM.

To store information in the EEPROM, you can add DATA lines to your programthat hold the data that must be stored in the EEPROM.

A separate file is generated with the EEP extension. This file can be used to programthe EEPROM.

The compiler must know which DATA must go into the code memory and which into the EEPROM memory and therefore two compiler directives were added.

$EEPROM and $DATA.

page -212-

© MCS Electronics, 1995-2007

$EEPROM tells the compiler that the DATA lines following the compiler directive must be stored in the EEP file.

To switch back to the default behavior of the DATA lines, you must use the $DATA directive.

The READ statement that is used to read the DATA info may only be used with normal DATA lines. It does not work with DATA stored in EEPROM.

Do not confuse $DATA directive with the DATA statement.

So while normal DATA lines will store the specified data into the code memory of the micro which is called the flash memory, the $EEPROM and $DATA will cause the data to be stored into the EEPROM. The EEP file is a binary file.

See also

$EEPROM , READEEPROM , WRITEEEPROM , DATA

ASM

NONE

Example

'-----------------------------------------------------------------------------

 

--

: (c) 1995-2005, MCS Electronics

'copyright

'micro

: AT90S2313

'suited for demo

: yes

'commercial addon needed

: no

'purpose

: demonstrates $DATA directive

'-----------------------------------------------------------------------------

 

--

 

$regfile = "2313def.dat"

 

$baud = 19200

' 4 MHz crystal

$crystal = 4000000

Dim B As Byte

'now B will be 1

Readeeprom B , 0

End

 

Dta: $eeprom

Data 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 $data

End

$EEPROMHEX

Action

Instruct the compiler to store the data in the EEP file in Intel HEX format instead of binary format.

page -213-

© MCS Electronics, 1995-2007

Syntax

$EEPROMHEX

Remarks

The AVR has build in EEPROM. With the WRITEEEPROM and READEEPROM statements, you can write and read to the EEPROM.

To store information in the EEPROM, you can add DATA lines to your programthat hold the data that must be stored in the EEPROM. $EEPROM must be used to create a EEP file that holds the data.

The EEP file is by default a binary file. When you use the STK500 you need an Intel HEX file. Use $EEPROMHEX to create an Intel Hex EEP file.

$EEPROMHEX must be used together with $EEPROM.

See also

$EEPROMLEAVE

Example

$eeprom'the following DATA lines data will go to the EEP file Data 200 , 100,50

$data

This would create an EEP file of 3 bytes. With the values 200,100 and 50. Add $eepromhex in order to create an Intel Hex file.

This is how the EEP filecontent looks when using $eepromhex

:0A00000001020304050A141E283251

:00000001FF

$EXTERNAL

Action

Instruct the compiler to include ASM routines from a library.

Syntax

$EXTERNAL Myroutine [, myroutine2]

Remarks

You can place ASM routines in a library file. With the $EXTERNAL directive you tell the compiler which routines must be included in your program.

See also

page -214-