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

© MCS Electronics, 1995-2007

Spmcrval = 17 : Gosub Do_spm

' re-enable page

End If

 

Next

'indication that

Toggle Portb.2 : Waitms 10 : Toggle Portb.2

we write

 

Return

 

Do_spm:

' check for

Bitwait Spmcsr.selfprgen , Reset

previous SPM complete

'wait for eeprom

Bitwait Eecr.eepe , Reset

Z = Page

'make equal to

page

'shift to proper

Shift Z , Left , Maxwordshift

place

'add word

Z = Z + Wrd

lds r30,{Z}

 

lds r31,{Z+1}

 

Spmcsr = Spmcrval

'assign register

spm

'this is an asm

instruction

 

nop

 

nop

 

Return

 

'How you need to use this program: '1- compile this program

'2- program into chip with sample elctronics programmer '3- select MCS Bootloader from programmers

'4- compile a new program for example M88.bas '5- press F4 and reset your micro

'the program will now be uploaded into the chip with Xmodem Checksum

'you can write your own loader. And we will release a command line loader in the future

$LOADERSIZE

Action

Instruct the compiler that a boot loader is used so it will not overwrite the boot space.

Syntax

$LOADERSIZE = size

Remarks

size

The amount of space that is used by the boot loader.

 

 

When you use a boot loader it will use space from the available flash memory. The compiler does not know if you use a boot loader or not. When your programexceeds the available space and runs into the boot sector space, it will overwrite the boot loader.

The $loadersize directive will take the boot loader size into account so you will get an error when the target file gets too big.

When you select the MCS bootloader as programmer the IDE also will take into account the specified boot loader size.

page -235-

© MCS Electronics, 1995-2007

The directive can be used when you have a different programmer selected. For example an external programmer that does not know about the boot size.

See also

$LOADER

ASM

NONE

Example

NONE

$MAP

Action

Will generate label info in the report.

Syntax

$MAP

Remarks

The $MAP directive will put an entry for each line number with the address into the report file. This info can be used for debugging purposes with other tools.

See also

NONE

ASM

NONE

Example

$MAP

The report file will not contain the following section :

Code map

--------------------------------------------------------------------------------

Line Address(hex)

--------------------------------------------------------------------------------

1

0

9

36

26

39

30

3B

31

3E

32

48

page -236-

© MCS Electronics, 1995-2007

33

4B

36

50

37

56

42

5B

43

6C

44

7D

45

80

46

81

$NOCOMP

Action

Instruct the compiler not to compile the file.

Syntax

$NOCOMP

Remarks

This looks like an odd directive. Since you can split your program in multiple files, and you can create configuration files, you might open a file and try to compile it. Only normal project files can be compiled and you will get a number of errors and also unwanted files like error, report, etc.

To prevent that you compile a file that is intended to be included, you can insert the $NOCOMP directive.

Then the file will only be compiled when it is called from your main file, or other include file.

A file that is opened as thus the main file, and which includes the $NOCOMP directive, can not be compiled.

The IDE will see it as a successful compilation. This is important for the Batch Compiler.

See also

Batch Compiler

Example

$NOCOMP

$NOINIT

Action

Instruct the compiler to generate code without initialization code.

Syntax

$NOINIT

page -237-

© MCS Electronics, 1995-2007

Remarks

$NOINIT is only needed in rare situations. It will instruct the compiler not to add initialization code. But that means that you need to write your own code then.

$NOINIT was added in order to support boot loaders. But the new $LOADER directive can better be used as it does not require special ASM knowledge.

See also

$LOADER

Example

$NORAMCLEAR

Action

Instruct the compiler to not generate initial RAM clear code.

Syntax

$NORAMCLEAR

Remarks

Normally the SRAM is cleared in the initialization code. When you don't want the SRAM to be cleared(set to 0) you can use this directive.

Because all variables are automatically set to 0 or ""(strings) without the $NORAMCLEAR, using $NORAMCLEAR will set the variables to an unknown value. That is, the variables will probably set to FF but you cannot count on it.

When you have a battery back upped circuit, you do not want to clear the RAM at start up. So that would be a situation when you could use $NORAMCLEAR.

See also

$NOINIT

$PROG

Action

Directive to auto program the lock and fuse bits.

Syntax

$PROG LB, FB , FBH , FBX

page -238-

© MCS Electronics, 1995-2007

Remarks

While the lock and fuse bits make the AVR customizable, the settings for your project can give some problems.

The $PROG directive will create a file with the project name and the PRG extension.

Every time you program the chip, it will check the lock and fuse bit settings and willchange them if needed.

So in a new chip, the lock and fuse bits will be set automatically. A chip that has been programmed with the desired settings will not be changed.

The programmer has an option to create the PRG file from the current chip settings.

The LB, FH, FBH and FBX values are stored in hexadecimal format in the PRJ file. You may use any notation as long as it is a numeric constant.

Some chips might not have a setting for FBH or FBX, or you might not want to set all values. In that case, do NOT specify the value. For example:

$PROG &H20 ,,,

This will only write the Lockbit settings.

$PROG ,,&H30,

This will only write the FBH settings.

LB

Lockbit settings

FB

Fusebit settings

FBH

Fusebit High settings

FBX

Extended Fusebit settings

 

 

Sometimes the data sheet refers to the Fusebit as the Fusebit Low settings.

The $PROG setting is only supported by the AVRISP, STK200/300, Sample Electronics and Universal MCS Programmer Interface. The USB-ISP programmer also supports the $PROG directive.

When you select the wrong Fuse bit, you could lock your chip. For example when you choose the wrong oscillator option, it could mean that the micro expects an external crystal oscillator. But when you connect a simple crystal, it will not work.

In these cases where you can not communicate with the micro anymore, the advise is to apply a clock signal to X1 input of the micro.

You can then select the proper fusebits again.

When you set the Lockbits, you can not read the chip content anymore. Only after erasing the chip, it could be reprogrammed again.

Once the lockbits and fuse bits are set, it is best to remark the $PROG directive. This because it takes more time to read and compare the bits every time.

See also

Programmers , $PROG

page -239-