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

© MCS Electronics, 1995-2007

Note that LBX is a compiled LIB file. In order to change the routines you need the commercial edition with the source code(lib files). After a change you should compile the library with the library manager.

See also

mcsbyte.lib

TCPIP

The TCPIP library allows you to use the W3100A internet chip fromwww.ininchip.com

MCS has developed a special development board that can get you started quickly with TCP/IP communication. Look at http://www.mcselec.com for more info.

The tcpip.lib with the ASM source is bundled with the MCS Easy TCP/IP PCBand/or the IIM7000 module.

The tcpip.lbx is shipped with BASCOM-AVR

The following functions are provided:

 

 

 

 

 

 

CONFIG TCPIP

 

Configures the W3100 chip.

 

 

 

 

 

 

GETSOCKET

 

Creates a socket for TCP/IP communication.

 

 

 

 

 

 

SOCKETCONN

 

Establishes a connection to a TCP/IP server.

 

 

ECT

 

 

 

 

 

 

 

 

SOCKETSTAT

 

Returns information of a socket.

 

 

 

 

 

 

TCPWRITE

 

Write data to a socket.

 

 

 

 

 

 

TCPWRITESTR

 

Sends a string to an open socket connection.

 

 

 

 

 

 

TCPREAD

 

Reads data from an open socket connection.

 

 

 

 

 

 

CLOSESOCKET

 

Closes a socket connection.

 

 

 

 

 

 

SOCKETLISTE

 

Opens a socket in server(listen) mode.

 

 

N

 

 

 

 

 

 

 

 

GETDSTIP

 

Returns the IP address of the peer.

 

 

 

 

 

 

GETDSTPORT

 

Returns the port number of the peer.

 

 

 

 

 

 

BASE64DEC

 

Converts Base-64 data into the original data.

 

 

 

 

 

 

BASE64ENC

 

Convert a string into a BASE64 encoded string.

 

 

 

 

 

 

MAKETCP

 

Encodes a constant or 4 byte constant/variables into an IP number

 

 

 

 

 

 

UDPWRITE

 

Write UDP data to a socket.

 

 

 

 

 

 

UDPWRITESTR

 

Sends a string via UDP.

 

 

 

 

 

 

UDPREAD

 

Reads data via UDP protocol.

 

 

 

 

 

 

page -730-

© MCS Electronics, 1995-2007

LCD

LCD4BUSY

BASCOM supports LCD displays in a way that you can choose all pins random. This is great for making a simple PCB but has the disadvantage of more code usage. BASCOM also does not use the WR-pin so that you can use this pin for other purposes.

The LCD4BUSY.LIB can be used when timing is critical.

The default LCD library uses delays to wait until the LCD is ready. The lcd4busy.lib is using an additional pin (WR) to read the status flag of the LCD.

The db4-db7 pins of the LCD must be connected to the higher nibble of the port.

The other pins can be defined.

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

' (c) 2004 MCS Electronics

' lcd4busy.bas shows how to use LCD with busy check '-----------------------------------------------------------------------

'code tested on a 8515 $regfile="8515def.dat"

'stk200 has 4 MHz $crystal= 4000000

'define the custom library 'uses 184 hex bytes total

$lib"lcd4busy.lib"

'define the used constants 'I used portA for testing Const _lcdport =Porta Const _lcdddr =Ddra Const _lcdin =Pina

Const _lcd_e = 1

Const _lcd_rw = 2

Const _lcd_rs = 3

'this is like always, define the kind of LCD ConfigLcd= 16 * 2

'and here some simple lcd code Cls

Lcd"test"

Lowerline

Lcd"this" End

LCD4.LIB

page -731-

© MCS Electronics, 1995-2007

The built in LCD driver for the PIN mode is written to support a worst case scenario where you use random pins of the microprocessor to drive the LCD pins.

This makes it easy to design your PCB but it needs more code.

When you want to have less code you need fixed pins for the LCD display.

With the statement $LIB "LCD4.LBX" you specify that the LCD4.LIB will be used.

The following connections are used in the asm code:

Rs = PortB.0

RW = PortB.1 we dont use the R/W option of the LCD in this version so connect to ground E = PortB.2

E2 = PortB.3 optional for lcd with 2 chips

Db4 = PortB.4 the data bits must be in a nibble to save code Db5 = PortB.5

Db6 = PortB.6

Db7 = PortB.7

You can change the lines from the lcd4.lib file to use another port. Just change the address used :

.EQU LCDDDR=$17 ; change to another address for DDRD ($11)

.EQU LCDPORT=$18 ; change to another address for PORTD ($12)

See the demo lcdcustom4bit.bas in the SAMPLES dir.

Note that you still must select the display that you use with theCONFIG LCD statement.

See also the lcd42.lib for driving displays with 2 E lines.

Note that LBX is a compiled LIB file. In order to change the routines you need the commercial edition with the source code(lib files). After a change you should compile the library with the library manager.

LCD4E2

The built in LCD driver for the PIN mode is written to support a worst case scenario where you use random pins of the microprocessor to drive the LCD pins.

This makes it easy to design your PCB but it needs more code.

When you want to have less code you need fixed pins for the LCD display.

With the statement $LIB "LCD4E2.LBX" you specify that the LCD4.LIBwill be used.

The following connections are used in the asm code: Rs = PortB.0

RW = PortB.1 we don’t use the R/W option of the LCD in this version so connect to ground E = PortB.2

E2 = PortB.3 the second E pin of the LCD

Db4 = PortB.4 the data bits must be in a nibble to save code Db5 = PortB.5

Db6 = PortB.6

Db7 = PortB.7

page -732-

© MCS Electronics, 1995-2007

You can change the lines from the lcd4e2.lib file to use another port. Just change the address used :

.EQU LCDDDR=$17 ; change to another address for DDRD ($11)

.EQU LCDPORT=$18 ; change to another address for PORTD ($12)

See the demo lcdcustom4bit2e.bas in the SAMPLES dir.

Note that you still must select the display that you use with theCONFIG LCD statement.

See also the lcd4.lib for driving a display with 1 E line.

A display with 2 E lines actually is a display with 2 control chips. They must both be controlled. This library allows you to select the active E line from your code.

In your basic code you must first select the E line before you use a LCDstatement.

The initialization of the display will handle both chips.

Note that LBX is a compiled LIB file. In order to change the routines you need the commercial edition with the source code(lib files). After a change you should compile the library with the library manager.

GLCD

GLCD.LIB (LBX) is a library for Graphic LCD’s based on the T6963C chip.

The library contains code for LOCATE, CLS, PSET, LINE, CIRCLE, SHOWPIC and SHOWPICE.

GLCDSED

GLCDSED.LIB (LBX) is a library for Graphic LCD’s based on the SEDXXXX chip.

The library contains modified code for this type of display.

New special statements for this display are :

LCDAT

SETFONT

GLCDCMD

GLCDDATA

See the SED.BAS sample from the sample directory

page -733-

© MCS Electronics, 1995-2007

PCF8533

COLOR LCD

Color displays were always relatively expensive. The mobile phone market changed that. And Display3000.com , sorted out how to connect these small nice colorfull displays. You can buy brand new Color displays from Display3000. MCS Electronics offers the same displays.

There are two different chip sets used. One chipset is from EPSON and the other from Philips. For this reason there are two different libraries. When you select the wrong one it will not work, but you will not damage anything.

LCD-EPSON.LBX need to be used with the EPSONchipset. LCD-PCF8833.LBX need to be used with the Philips chipset.

Config Graphlcd = Color , Controlport = Portc , Cs = 1 , Rs = 0 , Scl = 3 , Sda = 2

Controlport The port that is used to control the pins. PORTA, PORTB, etc.

CS

The chip select pin of the display screen. Specify the pin number. 1 will mean

 

PORTC.1

RS

The RESET pin of the display

SCL

The clock pin of the display

SDA

The data pin of the display

As the color display does not have a built in font, you need to generate the fonts yourself. You can use the Fonteditor for this task.

A number of statements accept a color parameter. See the samples below in bold.

LINE

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

LCDAT

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

CIRCLE

Circle(30 , 30) , 10 , Blue

PSET

32 , 110 , Black

BOX

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

 

 

See Also

LCD Graphic converter

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

page -734-

© MCS Electronics, 1995-2007

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

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"

page -735-