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

© MCS Electronics, 1995-2007

$PROGRAMMER

Action

Will set the programmer from the source code.

Syntax

$PROGRAMMER = number

Remarks

Number A numeric constant that identifies the programmer.

The $PROGRAMMER directive will set the programmer just before it starts programming. When you press F4 to program a chip, the selected programmer will be made active. This is convenient when you have different project open and use different programmers.

But it can also lead to frustration as you might think that you have the 'STK200' selected, and the directive will set it to USB-ISP.

The following values can be used :

 

 

 

 

 

Value

 

Programmer

 

 

 

 

0

 

AVR-ISP programmer(old AN 910)

 

 

 

 

1

 

STK200/STK300

 

 

 

 

2

 

PG302

 

 

 

 

3

 

External programmer

 

 

 

 

4

 

Sample Electronics

 

 

 

 

5

 

Eddie Mc Mullen

 

 

 

 

6

 

KITSRUS K122

 

 

 

 

7

 

STK500

 

 

 

 

8

 

Universal MCS Interface

 

 

 

 

9

 

STK500 extended

 

 

 

 

10

 

Lawicel Bootloader

 

 

 

 

11

 

MCS USB

 

 

 

 

12

 

USB-ISP I

 

 

 

 

13

 

MCS Bootloader

 

 

 

 

See also

$PROG

ASM

NONE

Example

page -240-

© MCS Electronics, 1995-2007

$REGFILE

$REGFILE

Action

Instruct the compiler to use the specified register file instead of the selected dat file.

Syntax

$REGFILE = "name"

Remarks

Name

The name of the register file. The register files are stored in the

 

BASCOM-AVR application directory and they all have the DAT extension.

 

The register file holds information about the chip such as the internal

 

registers and interrupt addresses.

 

The register file info is derived from atmel defenition files.

 

 

The $REGFILE statement overrides the setting from the Options, Compiler, Chip menu. The settings are stored in a <project>.CFG file.

The $REGFILE directive must be the first statement in your program. It may not be put into an included file since only the main source file is checked for the $REGFILE directive.

It is good practice to use the $REGFILE directive. It has the advantage that you can see at the source which chip it was written for.

The register files contain the hardware register names from the micro. They also contain the bit names. These are constants that you may use in your program. But the names can not be used to dim a variable for example.

Example :

DIM PORTA As Byte

This will not work as PORTA is a register constant.

See also

$SWSTACK , $HWSTACK , $FRAMESIZE

ASM

NONE

Example

$REGFILE = "8515DEF.DAT"

$ROMSTART

page -241-

© MCS Electronics, 1995-2007

Action

Instruct the compiler to generate a hex file that starts at the specified address.

Syntax

$ROMSTART = address

Remarks

Address

The address where the code must start. By default the first address is 0.

 

The bin file will still begin at address 0.

 

 

The $ROMFILE could be used to locate code at a different address for example for a boot loader.

It is best to use the new $LOADER directive to add boot loader support.

See also

$LOADER

ASM

NONE

Example

$ROMSTART = &H4000

$SERIALINPUT

Action

Specifies that serial input must be redirected.

Syntax

$SERIALINPUT = label

Remarks

Label

The name of the assembler routine that must be called when a character is

 

needed by the INPUT routine. The character must be returned in R24.

 

 

With the redirection of the INPUT command, you can use your own input routines.

This way you can use other devices as input devices.

Note that the INPUT statement is terminated when a RETURN code (13) is received.

By default when you use INPUT or INKEY(), the compiler will expect data from the COM port. When you want to use a keyboard or remote control as the input device you can write a custom routine that puts the data into register R24 once it needs this data.

page -242-

© MCS Electronics, 1995-2007

See also

$SERIALOUTPUT

Example

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

 

---

: $serialinput.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demonstrates $SERIALINPUT redirection of serial

input

: Mega48

'micro

'suited for demo

: yes

'commercial addon needed

: no

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

 

---

 

$regfile = "m48def.dat"

 

'define used crystal

 

$crystal = 4000000

 

$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 used variables

 

Dim S As String * 10

 

Dim W As Long

 

'inform the compiler which routine must be called to get serial characters $serialinput = Myinput

'make a never ending loop

Do

'ask for name Input "name " , S

Print S

'error is set on time out

Print "Error " ; Err

Loop

End

'custom character handling routine

'instead of saving and restoring only the used registers

'and write full ASM code, we use Pushall and PopAll to save and restore 'all registers so we can use all BASIC statements

'$SERIALINPUT requires that the character is passed back in R24 Myinput:

Pushall

'save all

registers

'reset counter

W = 0

Myinput1:

'increase counter

Incr W

Sbis USR, 7

' Wait for

character

 

page -243-