- •Table of Contents
- •Index
- •Keyword Reference
- •Installation
- •Installation of BASCOM
- •BASCOM IDE
- •Running BASCOM-AVR
- •File New
- •File Close
- •File Save
- •File Save As
- •File Print Preview
- •File Print
- •File Exit
- •View PinOut
- •View PDF viewer
- •View Error Panel
- •Edit Undo
- •Edit Redo
- •Edit Cut
- •Edit Copy
- •Edit Paste
- •Edit Find
- •Edit Find Next
- •Edit Replace
- •Edit Goto
- •Edit Toggle Bookmark
- •Edit Goto Bookmark
- •Edit Indent Block
- •Edit Unindent Block
- •Edit Remark Block
- •Program Compile
- •Program Syntax Check
- •Program Show Result
- •Program Simulate
- •Program Send to Chip
- •Tools Terminal Emulator
- •Tools LCD Designer
- •Tools LIB Manager
- •Tools Graphic Converter
- •Tools Stack Analyzer
- •Tools Plugin Manager
- •Tools Batch Compile
- •Options Compiler
- •Options Compiler Chip
- •Options Compiler Output
- •Options Compiler Communication
- •Options Compiler I2C, SPI, 1WIRE
- •Options Compiler LCD
- •Options Communication
- •Options Environment
- •Options Simulator
- •Options Programmer
- •Supported Programmers
- •ISP programmer
- •PG302 programmer
- •Sample Electronics cable programmer
- •KITSRUS Programmer
- •MCS Universal Interface Programmer
- •STK500 Programmer
- •Lawicel BootLoader
- •AVR ISP Programmer
- •USB-ISP Programmer
- •MCS Bootloader
- •Options Monitor
- •Options Printer
- •Window Cascade
- •Window Tile
- •Window Arrange Icons
- •Window Minimize All
- •Help About
- •Help Index
- •Help MCS Forum
- •Help MCS Shop
- •Help Support
- •Help Knowledge Base
- •Help Credits
- •BASCOM Editor Keys
- •Program Development Order
- •PlugIns
- •Font Editor
- •PinOut
- •BASCOM HARDWARE
- •Additional Hardware
- •AVR Internal Hardware
- •AVR Internal Registers
- •AVR Internal Hardware TIMER0
- •AVR Internal Hardware TIMER1
- •AVR Internal Hardware Watchdog timer
- •AVR Internal Hardware Port B
- •AVR Internal Hardware Port D
- •Adding XRAM
- •Attaching an LCD Display
- •Memory usage
- •Using the 1 WIRE protocol
- •Using the SPI protocol
- •Power Up
- •Chips
- •ATtiny22
- •ATtiny13
- •ATtiny15
- •ATtiny25
- •ATtiny45
- •ATtiny85
- •ATtiny26
- •ATtiny2313
- •ATMEGA8
- •ATMEGA16
- •ATMEGA32
- •ATMEGA48
- •ATMEGA88
- •ATMEGA168
- •ATMEGA64
- •ATMEGA103
- •ATMEGA128
- •ATMEGA161
- •ATMEGA162
- •ATMEGA163
- •ATMEGA165
- •ATMEGA169
- •ATMEGA323
- •ATMEGA603
- •ATMEGA8515
- •ATMEGA8535
- •BASCOM Language Fundamentals
- •Changes compared to BASCOM-8051
- •Language Fundamentals
- •Mixing ASM and BASIC
- •Assembler mnemonics
- •Reserved Words
- •Error Codes
- •Newbie problems
- •Tips and tricks
- •ASCII chart
- •BASCOM Language Reference
- •$BAUD
- •$BAUD1
- •$BOOT
- •$CRYSTAL
- •$DATA
- •$DEFAULT
- •$EEPLEAVE
- •$EEPROM
- •$EEPROMHEX
- •$EXTERNAL
- •$FRAMESIZE
- •$HWSTACK
- •$INCLUDE
- •$INITMICRO
- •$LCDPUTCTRL
- •$LCDPUTDATA
- •$LCDRS
- •$LCDVFO
- •$LOADER
- •$LOADERSIZE
- •$NOCOMP
- •$NOINIT
- •$NORAMCLEAR
- •$PROG
- •$PROGRAMMER
- •$REGFILE
- •$ROMSTART
- •$SERIALINPUT
- •$SERIALINPUT1
- •$SERIALINPUT2LCD
- •$SERIALOUTPUT
- •$SERIALOUTPUT1
- •$SWSTACK
- •$TIMEOUT
- •$TINY
- •$WAITSTATE
- •$XRAMSIZE
- •$XRAMSTART
- •1WIRECOUNT
- •1WRESET
- •1WREAD
- •1WSEARCHFIRST
- •1WSEARCHNEXT
- •1WVERIFY
- •1WWRITE
- •ACOS
- •ALIAS
- •ASIN
- •BASE64DEC
- •BASE64ENC
- •BAUD
- •BAUD1
- •BINVAL
- •BIN2GRAY
- •BITWAIT
- •BITS
- •BLOAD
- •BSAVE
- •BUFSPACE
- •BYVAL
- •CALL
- •CHECKSUM
- •CIRCLE
- •CLEAR
- •CLOCKDIVISION
- •CLOSE
- •CLOSESOCKET
- •CONFIG
- •CONFIG 1WIRE
- •CONFIG ACI
- •CONFIG ADC
- •CONFIG ATEMU
- •CONFIG BCCARD
- •CONFIG CLOCK
- •CONFIG CLOCKDIV
- •CONFIG COM1
- •CONFIG COM2
- •CONFIG COMx
- •CONFIG DATE
- •CONFIG DCF77
- •CONFIG DEBOUNCE
- •CONFIG I2CDELAY
- •CONFIG I2CSLAVE
- •CONFIG INPUT
- •CONFIG INTx
- •CONFIG GRAPHLCD
- •CONFIG KBD
- •CONFIG KEYBOARD
- •CONFIG LCD
- •CONFIG LCDBUS
- •CONFIG LCDMODE
- •CONFIG LCDPIN
- •CONFIG PORT
- •CONFIG PRINT
- •CONFIG PRINTBIN
- •CONFIG PS2EMU
- •CONFIG RC5
- •CONFIG SDA
- •CONFIG SCL
- •CONFIG SERIALIN
- •CONFIG SERIALIN1
- •CONFIG SERIALOUT
- •CONFIG SERIALOUT1
- •CONFIG SINGLE
- •CONFIG SPI
- •CONFIG SERVOS
- •CONFIG TCPIP
- •CONFIG TIMER0
- •CONFIG TIMER1
- •CONFIG TIMER2
- •CONFIG TWI
- •CONFIG TWISLAVE
- •CONFIG WAITSUART
- •CONFIG WATCHDOG
- •CONFIG X10
- •CONFIG XRAM
- •CONST
- •COSH
- •COUNTER0 and COUNTER1
- •CPEEK
- •CPEEKH
- •CRYSTAL
- •CURSOR
- •DATA
- •DAYOFWEEK
- •DAYOFYEAR
- •DATE$
- •DATE
- •DEBUG
- •DEBOUNCE
- •DECR
- •DECLARE FUNCTION
- •DECLARE SUB
- •DEFxxx
- •DEFLCDCHAR
- •DELAY
- •DISABLE
- •DISKFREE
- •DISKSIZE
- •DISPLAY
- •DO-LOOP
- •DriveCheck
- •DriveGetIdentity
- •DriveInit
- •DriveReset
- •DriveReadSector
- •DriveWriteSector
- •DTMFOUT
- •ECHO
- •ELSE
- •ENABLE
- •ENCODER
- •EXIT
- •FILEATTR
- •FILEDATE
- •FILEDATETIME
- •FILELEN
- •FILETIME
- •FLUSH
- •FORMAT
- •FOR-NEXT
- •FOURTHLINE
- •FRAC
- •FREEFILE
- •FUSING
- •GETADC
- •GETATKBD
- •GETATKBDRAW
- •GETDSTIP
- •GETDSTPORT
- •GETKBD
- •GETRC
- •GETRC5
- •GETTCPREGS
- •GETSOCKET
- •GLCDCMD
- •GLCDDATA
- •GOSUB
- •GOTO
- •GRAY2BIN
- •HEXVAL
- •HIGH
- •HIGHW
- •HOME
- •I2CINIT
- •I2CRECEIVE
- •I2CSEND
- •I2START,I2CSTOP, I2CRBYTE, I2CWBYTE
- •IDLE
- •IF-THEN-ELSE-END IF
- •INCR
- •INITFILESYSTEM
- •INITLCD
- •INKEY
- •INPUTBIN
- •INPUTHEX
- •INPUT
- •INSTR
- •ISCHARWAITING
- •KILL
- •LCASE
- •LCDAT
- •LCDCONTRAST
- •LEFT
- •LINE
- •LINE INPUT
- •LTRIM
- •LOAD
- •LOADADR
- •LOADLABEL
- •LOADWORDADR
- •LOCAL
- •LOCATE
- •LOOKDOWN
- •LOOKUP
- •LOOKUPSTR
- •LOWERLINE
- •MAKEBCD
- •MAKEINT
- •MAKEDEC
- •MAKETCP
- •MEMCOPY
- •NBITS
- •ON INTERRUPT
- •ON VALUE
- •OPEN
- •PEEK
- •POKE
- •POPALL
- •POWER
- •POWERDOWN
- •POWERSAVE
- •PRINTBIN
- •PSET
- •PS2MOUSEXY
- •PULSEIN
- •PULSEOUT
- •PUSHALL
- •RC5SEND
- •RC5SENDEXT
- •RC6SEND
- •READ
- •READEEPROM
- •READMAGCARD
- •RESET
- •RESTORE
- •RETURN
- •RIGHT
- •ROTATE
- •ROUND
- •RTRIM
- •SECELAPSED
- •SECOFDAY
- •SEEK
- •SELECT-CASE-END SELECT
- •SETFONT
- •SETTCP
- •SETTCPREGS
- •SENDSCAN
- •SENDSCANKBD
- •SERIN
- •SEROUT
- •SETIPPROTOCOL
- •SHIFT
- •SHIFTCURSOR
- •SHIFTIN
- •SHIFTOUT
- •SHIFTLCD
- •SHOWPIC
- •SHOWPICE
- •SINH
- •SOCKETCONNECT
- •SOCKETLISTEN
- •SOCKETSTAT
- •SONYSEND
- •SOUND
- •SPACE
- •SPIIN
- •SPIINIT
- •SPIMOVE
- •SPIOUT
- •SPLIT
- •START
- •STCHECK
- •STOP
- •STRING
- •SYSSEC
- •SYSSECELAPSED
- •SYSDAY
- •SWAP
- •TCPCHECKSUM
- •TCPREAD
- •TCPWRITE
- •TCPWRITESTR
- •TANH
- •THIRDLINE
- •TIME$
- •TIME
- •TOGGLE
- •TRIM
- •UCASE
- •UDPREAD
- •UDPWRITE
- •UDPWRITESTR
- •UPPERLINE
- •VARPTR
- •VERSION
- •WAIT
- •WAITKEY
- •WAITMS
- •WAITUS
- •WHILE-WEND
- •WRITE
- •WRITEEEPROM
- •X10DETECT
- •X10SEND
- •#IF ELSE ENDIF
- •International Resellers
- •International Resellers
- •ASM Libraries
- •EXTENDED I2C
- •MCSBYTE
- •MCSBYTEINT
- •TCPIP
- •LCD4BUSY
- •GLCD
- •GLCDSED
- •LCD-EPSON
- •AVR-DOS File System
- •CF Card
- •Compact FlashCard Driver
- •Elektor CF-Interface
- •XRAM CF-Interface for simulation
- •New CF-Card Drivers
- •Floating Point
- •FP_TRIG
- •DOUBLE
- •I2C SLAVE
- •I2CSLAVE
- •I2C TWI Slave
- •SPISLAVE
- •DATE TIME
- •EUROTIMEDATE
- •DATETIME
- •PS2-AT Mouse and Keyboard Emulation
- •AT_EMULATOR
- •PS2MOUSE_EMULATOR
- •BCCARD
- •BCCARD
- •BCDEF
- •BCCALL
- •BCRESET
- •Tools
- •LCD RGB-8 Converter
© 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-
