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

© MCS Electronics, 1995-2007

'Config Pind.2 = Input

Getrc5(address , Command)

'we check for the TV address and that is 0 If Address = 0 Then

'clear the toggle bit

'the toggle bit toggles on each new received command 'toggle bit is bit 7. Extended RC5 bit is in bit 6 Command = Command And &B01111111

Print Address ; " " ; Command

End If Loop End

GETTCPREGS

Action

Read a register value from the W3100A

Syntax

var = GETTCPREGS(address, bytes)

Remarks

Address

The address of the W3100A register.

bytes

The number of bytes to read.

 

 

Most W3100A options are implemented with BASCOM statements or functions. When there is a need to read from the W3100A register you can use the GETTCPREGS function. It can read multiple bytes. It is important that you specify the highest address. This because the registers must be read starting with the higest address.

See also

SETTCPREGS

ASM

NONE

Example

See SETTCPREGS

GETSOCKET

Action

Creates a socket for TCP/IP communication.

Syntax

page -514-

© MCS Electronics, 1995-2007

Result = GETSOCKET(socket, mode, port, param)

Remarks

Result

A byte that is assigned with the socket number you requested. When the

 

operation fails, it will return 255.

Mode

Port

Param

The socket mode. Use sock_stream(1), sock_dgrm(2), sock_ipl_raw(3), sock) or macl_raw(4). The modes are defined with constants.

For TCP/IP communication you need to specify sock_streamor the equivalent value 1.

For UDP communication you need to specify sock_dgrm or the equivalent value 2.

This is the local port that will be used for the communication. You may specify any value you like but each socket must have it’s own local port number.

When you use 0, the value of LOCAL_PORT will be used.

LOCAL_PORT is assigned with CONFIG TCPIP.

After the assignment, LOCAL_PORT will be increased by 1. So the simplest way is to setup a local port with CONFIG TCPIP, and then use 0 for port.

Optional parameter. Use 0 for default.

128 : send/receive broadcast message in UDP

64 : use register value with designated timeout value

32 : when not using no delayed ack

16: when not using silly window syndrome

Consult the W3100A documentation for more information.

After the socket has been initialized you can use SocketConnect to connect to a client, or SocketListen to act as a server.

See also

CONFIG TCPIP, SOCKETCONNECT, SOCKETSTAT , TCPWRITE, TCPWRITESTR, TCPREAD, CLOSESOCKET , SOCKETLISTEN

Partial Example

I = Getsocket(0 , Sock_stream , 5000 , 0)' get a new socket

GLCDCMD

Action

Sends a command byte to the SED graphical LCD display.

Syntax

page -515-

© MCS Electronics, 1995-2007

GLCDCMD byte

Remarks

byte A variable or numeric constant to send to the display.

With GLCDCMD you can write command bytes to the display. This is convenient to control the display when there is no specific statement available.

You need to include the glibSED library with : $LIB "glibsed.lbx"

See also

CONFIG GRAPHLCD , LCDAT, GLCDDATA

Example

NONE

GLCDDATA

Action

Sends a data byte to the SED graphical LCD display.

Syntax

GLCDDATA byte

Remarks

byte

A variable or numeric constant to send to the display.

 

 

With GLCDDATA you can write data bytes to the display. This is convenient to control the display when there is no specific statement available.

You need to include the glibSED library with :

$LIB "glibsed.lbx"

See also

CONFIG GRAPHLCD , LCDAT, GLCDCMD

Example

NONE

page -516-

© MCS Electronics, 1995-2007

GOSUB

Action

Branch to and execute subroutine.

Syntax

GOSUB label

Remarks

Label

The name of the label where to branch to.

 

 

With GOSUB, your program jumps to the specified label, and continues execution at that label.

When it encounters a RETURN statement, program execution will continue after the GOSUB statement.

See also

GOTO , CALL , RETURN

Example

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

 

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

: gosub.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo: GOTO, GOSUB and RETURN

'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

 

Goto Continue

 

Print "This code will not be executed"

 

Continue:

'end a label with

a colon

 

Print "We will start execution here"

 

Gosub Routine

 

Print "Back from Routine"

 

End

 

Routine:

'start a

page -517-