
- •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
r25: Error Code C-Flag on Error X: requested info
Partial Example
'for the binary file demo we need some variables of different types
Dim B As Byte , W As Word , L As Long , Sn As Single , Ltemp As Long Dim Stxt As String * 10
B = 1 : W = 50000 : L = 12345678 : Sn = 123.45 : Stxt = "test"
'open the file in BINARY mode |
|
Open "test.biN"for Binary As #2 |
|
Put#2 , B ' write a byte |
|
Put#2 , W ' write a word |
|
Put#2 , L ' write a long |
' get the position |
Ltemp = Loc(#2) + 1 |
|
of the next byte |
' store the |
Print Ltemp ; " LOC" |
|
location of the file pointer |
|
Print Seek(#2) ; " = LOC+1" |
|
Print Lof(#2) ; " length of file" |
' should be 32 for |
Print Fileattr(#2) ; " file mode" |
|
binary |
' write a single |
Put #2 , Sn |
|
Put #2 , Stxt |
' write a string |
Flush #2 |
' flush to disk |
Close #2 |
|
'now open the file again and write only the single |
|
Open "test.bin" For Binary As #2 |
|
L = 1 'specify the file position |
' reset is the |
B = Seek(#2 , L) |
|
same as using SEEK #2,L |
|
Get#2 , B ' get the byte |
|
Get#2 , W ' get the word |
|
Get#2 , L ' get the long |
|
Get#2 , Sn ' get the single |
|
Get#2 , Stxt ' get the string |
|
Close #2 |
|
GETADC
Action
Retrieves the analog value from channel 0-7.
Syntax
var = GETADC(channel [,offset])
Remarks
Var |
The variable that is assigned with the A/D value |
Channel |
The channel to measure. Might be higher then 7 on some chips. |
page -500-
|
© MCS Electronics, 1995-2007 |
|
|
|
|
Offset |
An optional numeric variable of constant that specifies gain or mode. This |
|
|
option has effect on newer AVR micro’s only. The offset will be added by the |
|
|
channel value and inserted into the ADMUX register. |
|
The GETADC() function only will work on microprocessors that have an A/Dconverter. The pins of the A/D converter input can be used for digital I/O too.
But it is important that no I/O switching is done while using the A/D converter.
Make sure you turn on the AD converter with the START ADC statement or by setting the proper bit in the ADC configuration register.
Some micro’s have more then 7 channels. This is supported as well.
GetADC() returns a word variable since the A/D converter data registers consist of 2 registers. The resolution depends on the chip.
The variable ADCD can be used to access the data register directly. The compiler will handle access to the byte registers automatically.
See also
CONFIG ADC
Example
'----------------------------------------------------------------------------- |
|
--- |
: adc.bas |
'name |
|
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: demonstration of GETADC() function for 8535 or |
M163 micro |
: Mega163 |
'micro |
|
'suited for demo |
: yes |
'commercial addon needed |
: no |
'use in simulator |
: possible |
' Getadc() will also work for other AVR chips that have an ADC converter |
|
'----------------------------------------------------------------------------- |
|
--- |
' we use the M163 |
$regfile = "m163def.dat" |
|
$crystal = 4000000 |
|
$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 |
|
'configure single mode and auto prescaler setting
'The single mode must be used with the GETADC() function
'The prescaler divides the internal clock by 2,4,8,16,32,64 or 128 'Because the ADC needs a clock from 50-200 KHz
'The AUTO feature, will select the highest clockrate possible Config Adc = Single , Prescaler = Auto
'Now give power to the chip
Start Adc
'With STOP ADC, you can remove the power from the chip 'Stop Adc
Dim W As Word , Channel As Byte
Channel = 0
page -501-

© MCS Electronics, 1995-2007
'now read A/D value from channel 0
Do
W = Getadc(channel)
Print "Channel " ; Channel ; " value " ; W Incr Channel
If Channel > 7 Then Channel = 0
Loop
End
'The new M163 has options for the reference voltage 'For this chip you can use the additional param :
'Config Adc = Single , Prescaler = Auto, Reference = Internal 'The reference param may be :
'OFF |
: |
AREF, |
internal reference turned off |
'AVCC |
: |
AVCC, |
with external capacitor at AREF pin |
'INTERNAL : Internal 2.56 voltage reference with external capacitor ar AREF pin
'Using the additional param on chip that do not have the internal reference will have no effect.
GETATKBD
Action
Reads a key from a PC AT keyboard.
Syntax
var = GETATKBD()
Remarks
var |
The variable that is assigned with the key read fromthe |
|
keyboard. |
|
It may be a byte or a string variable. |
|
When no key is pressed a 0 will be returned. |
|
|
The GETAKBD() function needs 2 input pins and a translation table for the keys. You can read more about this at the CONFIG KEYBOARD compiler directive.
The Getatkbd function will wait for a pressed key. When you want to escape fromthe waiting loop you can set the ERR bit from an interrupt routine for example.
Getatkbd is using 2 bits from register R6 : bit 4 and 5 are used to hold the shift and control key status.
AT KEYBOARD SCANCODES
Table reprinted with permission of Adam Chapweske
http://panda.cs.ndsu.nodak.edu/~achapwes
KEY |
MAKE |
BREAK |
|
KEY |
MAKE |
BREAK |
|
KEY |
MAKE |
BREAK |
A |
1C |
F0,1C |
|
9 |
46 |
F0,46 |
|
[ |
54 |
FO,54 |
page -502-

© MCS Electronics, 1995-2007
B |
32 |
F0,32 |
|
|
|
C |
21 |
F0,21 |
|
|
|
D |
23 |
F0,23 |
|
|
|
E |
24 |
F0,24 |
|
|
|
F |
2B |
F0,2B |
|
|
|
G |
34 |
F0,34 |
|
|
|
H |
33 |
F0,33 |
|
|
|
I |
43 |
F0,43 |
|
|
|
J |
3B |
F0,3B |
|
|
|
K |
42 |
F0,42 |
|
|
|
L |
4B |
F0,4B |
M |
3A |
F0,3A |
|
|
|
N |
31 |
F0,31 |
O |
44 |
F0,44 |
P |
4D |
F0,4D |
Q |
15 |
F0,15 |
|
|
|
R |
2D |
F0,2D |
S |
1B |
F0,1B |
T |
2C |
F0,2C |
U |
3C |
F0,3C |
V |
2A |
F0,2A |
W |
1D |
F0,1D |
X |
22 |
F0,22 |
Y |
35 |
F0,35 |
Z |
1A |
F0,1A |
0 |
45 |
F0,45 |
1 |
16 |
F0,16 |
2 |
1E |
F0,1E |
3 |
26 |
F0,26 |
4 |
25 |
F0,25 |
5 |
2E |
F0,2E |
6 |
36 |
F0,36 |
|
|
|
7 |
3D |
F0,3D |
8 |
3E |
F0,3E |
|
|
|
` |
0E |
F0,0E |
|
|
|
- |
4E |
F0,4E |
|
|
|
= |
55 |
FO,55 |
|
|
|
\ |
5D |
F0,5D |
|
|
|
BKSP |
66 |
F0,66 |
|
|
|
SPACE |
29 |
F0,29 |
|
|
|
TAB |
0D |
F0,0D |
|
|
|
CAPS |
58 |
F0,58 |
|
|
|
L SHFT |
12 |
FO,12 |
|
|
|
L CTRL |
14 |
FO,14 |
|
|
|
L GUI |
E0,1F |
E0,F0,1F |
L ALT |
11 |
F0,11 |
|
|
|
R SHFT |
59 |
F0,59 |
R CTRL |
E0,14 |
E0,F0,14 |
R GUI |
E0,27 |
E0,F0,27 |
R ALT |
E0,11 |
E0,F0,11 |
|
|
|
APPS |
E0,2F |
E0,F0,2F |
ENTER |
5A |
F0,5A |
ESC |
76 |
F0,76 |
F1 |
05 |
F0,05 |
F2 |
06 |
F0,06 |
F3 |
04 |
F0,04 |
F4 |
0C |
F0,0C |
F5 |
03 |
F0,03 |
F6 |
0B |
F0,0B |
F7 |
83 |
F0,83 |
F8 |
0A |
F0,0A |
F9 |
01 |
F0,01 |
F10 |
09 |
F0,09 |
F11 |
78 |
F0,78 |
F12 |
07 |
F0,07 |
PRNT |
E0,12, |
E0,F0, |
SCRN |
E0,7C 7C,E0, |
|
|
|
F0,12 |
SCROLL |
7E |
F0,7E |
PAUSE |
E1,14, -NONE- |
|
|
77, |
|
|
E1,F0, |
|
INSERT |
E0,70 |
E0,F0,7 |
|
|
0 |
HOME |
E0,6C |
E0,F0,6 |
|
|
C |
PG UP |
E0,7D |
E0,F0,7 |
|
|
D |
DELETE |
E0,71 |
E0,F0,7 |
|
|
1 |
END |
E0,69 |
E0,F0,6 |
|
|
9 |
PG DN |
E0,7A |
E0,F0,7 |
|
|
A |
U ARROW |
E0,75 |
E0,F0,7 |
|
|
5 |
L ARROW |
E0,6B |
E0,F0,6 |
|
|
B |
D ARROW |
E0,72 |
E0,F0,7 |
|
|
2 |
R ARROW |
E0,74 |
E0,F0,7 |
|
|
4 |
NUM |
77 |
F0,77 |
KP / |
E0,4A |
E0,F0,4 |
|
|
A |
KP * |
7C |
F0,7C |
KP - |
7B |
F0,7B |
KP + |
79 |
F0,79 |
KP EN |
E0,5A |
E0,F0,5 |
|
|
A |
KP . |
71 |
F0,71 |
KP 0 |
70 |
F0,70 |
KP 1 |
69 |
F0,69 |
KP 2 |
72 |
F0,72 |
KP 3 |
7A |
F0,7A |
KP 4 |
6B |
F0,6B |
KP 5 |
73 |
F0,73 |
KP 6 |
74 |
F0,74 |
KP 7 |
6C |
F0,6C |
KP 8 |
75 |
F0,75 |
KP 9 |
7D |
F0,7D |
] |
5B |
F0,5B |
; |
4C |
F0,4C |
' |
52 |
F0,52 |
, |
41 |
F0,41 |
. |
49 |
F0,49 |
|
|
|
/ |
4A |
F0,4A |
|
|
|
page -503-

© MCS Electronics, 1995-2007
14, |
F0,77 |
These are the usable scan codes from the keyboard. If you want to implement F1 , you look at the generated scan code : 05 hex. So in the table, at position 5+1=6, you write the value for F1.
In the sample program below, you can find the value 200. When you now press F1, the value form the table will be used so 200 will be returned.
See also
CONFIG KEYBOARD , GETATKBDRAW
Example
'----------------------------------------------------------------------------- |
|
------------ |
: getatkbd.bas |
'name |
|
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: PC AT-KEYBOARD Sample |
'micro |
: Mega48 |
'suited for demo |
: yes |
'commercial addon needed |
: no |
'-----------------------------------------------------------------------------
------------
$regfile = "8535def.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 |
|
'For this example :
'connect PC AT keyboard clock to PIND.2 on the 8535 'connect PC AT keyboard data to PIND.4 on the 8535
'The GetATKBD() function does not use an interrupt. 'But it waits until a key was pressed!
'configure the pins to use for the clock and data 'can be any pin that can serve as an input 'Keydata is the label of the key translation table
Config Keyboard = Pind.2 , Data = Pind.4 , Keydata = Keydata
'Dim some used variables
Dim S As String * 12 Dim B As Byte
'In this example we use SERIAL(COM) INPUT redirection $serialinput = Kbdinput
'Show the program is running Print "hello"
page -504-

© MCS Electronics, 1995-2007
Do
'The following code is remarked but show how to use the GetATKBD() function ' B = Getatkbd() 'get a byte and store it into byte variable
'When no real key is pressed the result is 0 'So test if the result was > 0
'If B > 0 Then
'Print B ; Chr(b)
'End If
'The purpose of this sample was how to use a PC AT keyboard
'The input that normally comes from the serial port is redirected to the 'external keyboard so you use it to type
Input "Name " , S 'and show the result
Print S
'now wait for the F1 key , we defined the number 200 for F1 in the table
Do
B = Getatkbd() Loop Until B <> 0 Print B
Loop
End
'Since we do a redirection we call the routine from the redirection routine
'
Kbdinput:
'we come here when input is required from the COM port 'So we pass the key into R24 with the GetATkbd function
' We need some ASM code to save the registers used by the function $asm
push r16 ; save used register push r25
push r26 push r27
Kbdinput1: |
; call the function |
rCall _getatkbd |
|
tst r24 |
; check for zero |
breq Kbdinput1 |
; yes so try again |
pop r27 |
; we got a valid key so restore registers |
pop r26 |
|
pop r25 |
|
pop r16 |
|
$end Asm |
|
'just return |
|
Return |
|
'The tricky part is that you MUST include a normal call to the routine 'otherwise you get an error
'This is no clean solution and will be changed B = Getatkbd()
'This is the key translation table
Keydata:
'normal keys lower case
Data 0 , 0 , 0 , 0 , 0 , 200 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , &H5E , 0
Data 0 , 0 , 0 , 0 , 0 , 113 , 49 , 0 , 0 , 0 , 122 , 115 , 97 , 119 , 50 , 0 Data 0 , 99 , 120 , 100 , 101 , 52 , 51 , 0 , 0 , 32 , 118 , 102 , 116 , 114 , 53 , 0
Data 0 , 110 , 98 , 104 , 103 , 121 , 54 , 7 , 8 , 44 , 109 , 106 , 117 , 55 , 56 , 0
Data 0 , 44 , 107 , 105 , 111 , 48 , 57 , 0 , 0 , 46 , 45 , 108 , 48 , 112 , 43 , 0
Data 0 , 0 , 0 , 0 , 0 , 92 , 0 , 0 , 0 , 0 , 13 , 0 , 0 , 92 , 0 , 0
page -505-