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

© MCS Electronics, 1995-2007

Valid bits are in range from 0 to 7.

See Also

NBITS

Example

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

 

---

: bits-nbits.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo for Bits() AND Nbits()

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'use in simulator

: possible

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

---

$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

 

Dim B As Byte

 

'while you can use &B notation for setting bits, like B = &B1000_0111 'there is also an alternative by specifying the bits to set

B = Bits(0 , 1 , 2 , 7) 'set only bit 0,1,2 and 7

Print B

'and while bits() will set all bits specified to 1, there is also Nbits() 'the N is for NOT. Nbits(1,2) means, set all bits except 1 and 2

B = Nbits(7) 'do not set bit 7

Print B

End

BLOAD

Action

Writes the Content of a File into SRAM

Syntax

BLoad sFileName, wSRAMPointer

page -289-

 

© MCS Electronics, 1995-2007

Remarks

 

 

sFileName

(String) Name of the File to be read

 

wSRAMPointer

(Word) Variable, which holds the SRAM Address to which the content

 

 

of the file should be written

 

 

 

 

This function writes the content of a file to a desired space in SRAM. A free handle is needed for this function.

See also

INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOC, LOF , EOF , FREEFILE , FILEATTR , SEEK , BSAVE , KILL , DISKFREE , DISKSIZE , GET , PUT , FILEDATE , FILETIME , FILEDATETIME , DIR , FILELEN , WRITE , INPUT

ASM

Calls

_BLoad

 

Input

X: Pointer to string

Z: Pointer to Long-variable, which holds the start position of

 

with filename

SRAM

Output

r25: Errorcode

C-Flag: Set on Error

 

 

 

Example

' THIS IS A CODE FRAGMENT, it needs AVR-DOS in order to work

'now the good old bsave and bload

 

Dim Ar(100)as Byte , I Asbyte

 

For I = 1 To 100

' fill the array

Ar(i) = I

Next

 

Wait 2

 

W = Varptr(ar(1))

 

Bsave"josef.img", W , 100

 

For I = 1 To 100

' reset the array

Ar(i) = 0

Next

 

Bload "josef.img" , W

' Josef you are

amazing !

 

For I = 1 To 10

 

Print Ar(i) ; " ";

 

Next

 

Print

 

BOX

Action

Create a filled box on a graphical display.

page -290-

© MCS Electronics, 1995-2007

Syntax

BOX (x1,y1) - (x2,y2) , color

Remarks

x1

The left corner position of the box

y1

The top position of the box

x2

The right corner position of the box

y2

The bottom position of the box

color

The color to use to fill the box

 

 

The BOX command will only work on Color displays. In a future version it will be implemented for other graphical displays as well.

The BOX command will create a filled box with the specified color.

See also

LINE, CIRCLE

ASM

NONE

Example

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

'The support for this display has been made possible by Peter Küsters from (c) Display3000

'You can buy the displays from Display3000 or MCS Electronics

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

'

'

'special color display support

$lib"lcd-pcf8833.lbx"

$regfile= "m88def.dat"

'ATMega 8, change if using different processors

$crystal= 8000000

'8 MHz

'First we define that we use a graphic LCD

Config Graphlcd = Color,Controlport= Portc,Cs = 1,Rs = 0,Scl= 3,Sda = 2 'here we define the colors

Const Blue= &B00000011

''predefined contants are making programming easier

Const Yellow= &B11111100

 

Const Red = &B11100000

 

Const Green = &B00011100

 

Const Black= &B00000000

 

Const White = &B11111111

 

Const Brightgreen = &B00111110

 

Const Darkgreen = &B00010100

 

Const Darkred = &B10100000

 

Const Darkblue = &B00000010

 

Const Brightblue= &B00011111

 

Const Orange = &B11111000

 

'clear the display

 

Cls

 

'create a cross

 

Line(0 ,0)-(130 , 130),Blue

 

Line(130 ,0)-(0 , 130), Red

 

Waitms 1000

 

'show an RLE encoded picture

 

Showpic 0,0,Plaatje

 

Showpic 40 ,40 ,Plaatje

 

page -291-

© MCS Electronics, 1995-2007

Waitms 1000

'select a font Setfont Color16x16 'and show some text

Lcdat 100 ,0,"12345678",Blue,Yellow

Waitms 1000

Circle(30 ,30),10 ,Blue

Waitms 1000 'make a box

Box(10 ,30)-(60 , 100), Red

'set some pixels Pset 32 ,110 ,Black Pset 38 ,110 ,Black Pset 35 ,112 ,Black

End

Plaatje: $bgf"a.bgc"

$include"color.font" $include"color16x16.font"

BSAVE

Action

Save a range in SRAM to a File

Syntax

BSave sFileName, wSRAMPointer, wLength

Remarks

sFileName

(String) Name of the File to be written

wSRAMPointer

(Word) Variable, which holds the SRAM Address, fromwhere SRAM

 

should be written to a File

wLength

(Word) Count of Bytes from SRAM, which should be written to the file

 

 

This function writes a range from the SRAM to a file. A free file handle is needed for this function.

See also

INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOC, LOF , EOF , FREEFILE , FILEATTR , SEEK , BLOAD , KILL , DISKFREE , DISKSIZE , GET , PUT , FILEDATE , FILETIME , FILEDATETIME , DIR , FILELEN , WRITE , INPUT

ASM

Calls _BSave

page -292-