ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 12.06.2025

Просмотров: 8218

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

© MCS Electronics, 1995-2007

Remarks

Int

The interrupt used such as INT0 or INT1.

DATA

The pin that is connected to the DATA line. This must be the same pin as the

used interrupt.

CLOCK

The pin that is connected to the CLOCK line.

Male

Female

5-pin DIN

(AT/XT):

1 - Clock

2 - Data

3 - Not

(Plug)

(Socket)

Implemented

4 - Ground

5 - +5v

Male

Female

6-pin Mini-DIN

(PS/2):

1 - Data

2 - Not

Implemented

(Plug)

(Socket)

3 - Ground

4 - +5v

5 - Clock

6 - Not

Implemented

Old PC’s are equipped with a 5-pin DIN female connector. Newer PC’s have a 6-pin mini DIN female connector.

The male sockets must be used for the connection with the micro.

Besides the DATA and CLOCK you need to connect fromthe PC to the micro, you need to connect ground. You can use the +5V from the PC to power your microprocessor.

The config statement will setup an ISR that is triggered when the INT pin goes low. This routine you can find in the library.

The ISR will retrieve a byte from the PC and will send the proper commands back to the PC.

The SENDSCANKBD statement allows you to send keyboard commands.

Note that unlike the mouse emulator, the keyboard emulator is also recognized after your PC has booted.

The PS2 Keyboard and mouse emulator needs an additonal commercial addon library.

See also

page -317-


© MCS Electronics, 1995-2007

SENDSCANKBD

Example

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

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

: ps2_kbdemul.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: PS2 AT Keyboard emulator

'micro

: 90S2313

'suited for demo

: no, ADD ONE NEEDED

'commercial addon needed

: yes

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

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

$regfile = "2313def.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

$lib "mcsbyteint.lbx"

' use optional lib

since we use only bytes

'configure PS2 AT pins

' you need to turn

Enable Interrupts

on interrupts yourself since an INT is used

Config Atemu = Int1 , Data = Pind.3 , Clock = Pinb.0

'

^------------------------

used interrupt

'

^-----------

pin connected to DATA

'

^--

pin connected to clock

'Note that the DATA must be connected to the used interrupt pin

Waitms 500

' optional delay

'rcall _AT_KBD_INIT

Print "Press t for test, and set focus to the editor window"

Dim Key2 As Byte , Key As Byte

Do

' get key from

Key2 = Waitkey()

terminal

Select Case Key2

Case "t" :

Waitms 1500

' send a scan code

Sendscankbd Mark

Case Else

End Select

Loop

Print Hex(key)

Mark:

' send mark

Data 12 , &H3A , &HF0 , &H3A , &H1C , &HF0 , &H1C , &H2D , &HF0 , &H2D , &H42

, &HF0 , &H42

'^ send 12 bytes

'

m

a

r

k

page -318-


© MCS Electronics, 1995-2007

CONFIG BCCARD

Action

Initializes the pins that are connected to the BasicCard.

Syntax

CONFIG BCCARD = port , IO=pin, RESET=pin

Remarks

Port

The PORT of the micro that is connected to the BasicCard. This can

be B or D for most micro’s. (PORTB and PORTD)

IO

The pin number that is connected to the IO of the BasicCard. Must

be in the range from 0-7

RESET

The pin number that is connected to the RESET of the BasicCard.

Must be in the range from 0-7

The variables SW1, SW2 and _BC_PCB are automatically dimensioned by the CONFIG BCCARD statement.

This statements uses BCCARD.LIB, a library that is available separately fromMCS Electronics.

See Also

BCRESET , BCDEF , BCCALL

Example

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

-

BCCARD.BAS

'

' This AN shows how to use the BasicCard from Zeitcontrol

'

www.basiccard.com

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

-

'connections:

'C1 = +5V

'C2 = PORTD.4 - RESET

' C3 = PIN 4 - CLOCK

'C5 = GND

'C7 = PORTD.5 - I/O

'

/--------------------------------

\

'

|

C1

C5

|

'

|

|

'

|

C2

C6

|

'

|

C3

C7

|

'

|

C4

C8

|

'

|

|

'

\--------------------------------

/

'

page -319-


© MCS Electronics, 1995-2007

'

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

configure the pins we use ------------

Config Bccard = D , Io = 5 , Reset = 4

'

^

^ PORTD.4

'

PORTD.5

'

^---------------------

PORT D

'Load the sample calc.bas into the basiccard

'Now define the procedure in BASCOM

'We pass a string and also receive a string

Bcdef Calc(string)

'We need to dim the following variables 'SW1 and SW2 are returned by the BasicCard

'BC_PCB must be set to 0 before you start a session

'Our program uses a string to pass the data so DIM it

Dim S As String * 15

'Baudrate might be changed $baud = 9600

' Crystal used must be 3579545 since it is connected to the Card too $crystal = 3579545

'Perform an ATR

Bcreset

'Now we call the procedure in the BasicCard

'bccall funcname(nad,cla,ins,p1,p2,PRM as TYPE,PRM as TYPE)

S = "1+1+3" ' we want to calculate the result of this expression

Bccall Calc(0 , &H20 , 1 , 0 , 0 , S)

variable to pass that holds the

'

^---

expression

^

P2

'

'

^-----------

P1

'

^---------------

INS

'

^--------------------

CLA

'^-------------------------- NAD

'For info about NAD, CLA, INS, P1 and P2 see your BasicCard manual 'if an error occurs ERR is set

' The BCCALL returns also the variables SW1 and SW2 Print "Result of calc : " ; S

Print "SW1 = " ; Hex(sw1)

Print "SW2 = " ; Hex(sw2)

'Print Hex(_bc_pcb) ' for test you can see that it toggles between 0 and 40 Print "Error : " ; Err

'You can call this or another function again in this session

S = "2+2"

Bccall Calc(0 , &H20 , 1 , 0 , 0 , S) Print "Result of calc : " ; S

Print "SW1 = " ; Hex(sw1)

Print "SW2 = " ; Hex(sw2)

'Print Hex(_bc_pcb) ' for test you can see that it toggles between 0 and 40 Print "Error : " ; Err

page -320-