6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 10:00 am

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Dec 09, 2012 6:57 pm 
Offline
User avatar

Joined: Sat Dec 01, 2012 10:31 pm
Posts: 16
Location: England.
looks about right :)
in that case then, if you Really wanted to, you could swap out the PS2 connector on the board and put a USB Female one in its place if you needed a smaller form factor.
the neat thing with the clock/data lines is that even if you did get them the wrong way around first try, it just wouldn`t work but no damage would be done (it happened to me), Not a good idea with the power rail though! >:D

_________________
Also on Twitter as "YT2095".


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 10, 2012 2:29 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
YT2095 wrote:
yeah, SBC to PC is pretty easy with the FTDI chips (about £2 on ebay), or even the PIC 18f22k50, 18f2550/4550.
the s/ware I did was the other way around, where it parses a USB Keyboards data into Parallel and Serial output for the SBC to use.

as for the green adapters I`v no idea if they`re different at all, but it would be worth checking with a continuity tester to see if it is just a simple pass-through type.

on the off chance that it May help someone in the future doing a search for such a thing, my code is here:

;Chip Settings
#chip 18F4685,20
#config OSC=HS, PWRT=ON, WDT=OFF

;Defines (Constants)
#define PS2Clock PORTB.1 'to D+ on USB socket
#define PS2Data PORTB.0 'to D- on USB socket
#define SerOutPort PORTB.7
#define SendAHigh Set SerOutPort Off
#define SendALow Set SerOutPort On

dir portc out
DIR PS2Clock IN
DIR PS2Data IN
Dir SerOutPort Out
InitSer 1, r9600, 1 + WaitForStart, 8, 1, None, Invert
Main:
KeyIn = INKEY
if KeyIn = 0 then
goto Main
end if
portc = KeyIn
SerSend 1, KeyIn
wait 1 ms
goto Main


all you need is to download GCBasic (it`s free and quite small), hook up a PIC 18F4685 with a 20MHz crystal to a PicKit2 and go to `Compile an download with PicKit2` in the pulldown menu and it`s done!
this will do both USB and/or PS2 directly with or without the use of adapters.

it hardly even deserves to be called "Code" :wink:


Here is my code for the pic16f877 you can use any part or all of it. It uses the onboard PSP as the interface, and when you write a byte it writes it to the LCD. It supports caps lock, and numlock and scroll lock leds work as well, although they re useless. It also beeps when it receives char 7.
It should be also able to read time and date from an i2c rtc chip, but there is a bug in the i2c routine, so i never got to fixing it.

Here is the code, but i must give credit to 8BIT, since i took the character table from his keyboard interface mcu. For compiling you need Proton IDE.
Code:
'****************************************************************
'*  Name    : ATC.BAS                                           *
'*  Author  : [select VIEW...EDITOR OPTIONS]                    *
'*  Notice  : Copyleft (c) 2011                                *
'*          : All Rights Reserved                               *
'*  Date    : 4.7.2011                                          *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
Device 16F877
XTAL=20
Output PORTB
Output PORTA
Input PORTE
Output PORTA.7

Declare LCD_TYPE ALPHA
Declare LCD_DTPIN PORTB.4     ' Used for 4-line interface.
Declare LCD_ENPIN PORTB.3
Declare LCD_RSPIN PORTB.2
Declare LCD_INTERFACE 4
Declare LCD_LINES 4

TRISE.4=1
Symbol CLK=PORTC.1
Symbol DAT=PORTC.0
Dim MODE As Bit
Dim ZY As Bit
Symbol NC=PORTA.5
Symbol ACK=PORTC.6
Symbol IRQ=PORTC.7
Symbol OUT=PORTD
Symbol INP=PORTD
Dim cbuf[128] As Byte
Dim cbrp As Byte
Dim cbwp As Byte
cbrp=0
cbwp=0
Dim VAR1 As Byte
Dim ict As Byte
Symbol Control %11010000
Symbol SDA = PORTB.0           ' Alias the SDA (Data) line
Symbol SCL = PORTB.1           ' Alias the SSL (Clock) line
Dim ADDR    As Byte      ' The address of the I2C device you wish to access
Dim I2C_OUT[2] As Byte   '[2] is maximum bytes being sent out, can change to send more
Dim I2C_IN[2]  As Byte   '[2] is maximum bytes being sent in, can chage to receive more
Dim TEMP    As Word
Dim I2C_ACK As Bit     'ACK bit receive
Dim Nw       As Byte    '”FOR” loop Variable
Dim FLAGw    As Byte    'FLAG Variable for Bytes to send/receive
Dim RWw      As Bit     'Read/Write bit variable used by subroutines
ADDR=Control
Symbol IBF=TRISE.7
Symbol OBF=TRISE.6
ADCON1=7
'PSPIF   rw operation ocurred
     
Declare FSR_CONTEXT_SAVE = On
On_Hardware_Interrupt GoTo Sio

'           norm    shift     scancode
Data      $00,   $00      ' 00 no key pressed   
Data      $89,   $C9      ' 01 F9   
Data      $87,   $C7      ' 02 relocated F7   
Data      $85,   $C5      ' 03 F5   
Data      $83,   $C3      ' 04 F3   
Data      $81,   $C1      ' 05 F1   
Data      $82,   $C2      ' 06 F2   
Data      $8C,   $CC      ' 07 F12   
Data      $00,   $00      ' 08   
Data      $8A,   $CA      ' 09 F10   
Data      $88,   $C8      ' 0A F8   
Data      $86,   $C6      ' 0B F6   
Data      $84,   $C4      ' 0C F4   
Data      $09,   $09      ' 0D tab   
Data      $60,   $7E      ' 0E `~   
Data      $8F,   $CF      ' 0F relocated Print Screen key   
Data      $03,   $03      ' 10 relocated Pause/Break key   
Data      $A0,   $A0      ' 11 left alt (right alt too)   
Data      $00,   $00      ' 12 left shift   
Data      $00,   $00      ' 13
Data      $00,   $00      ' 14 left ctrl (right ctrl too)   
Data      $71,   $51      ' 15 qQ   
Data      $31,   $21      ' 16 1!   
Data      $00,   $00      ' 17   
Data      $00,   $00      ' 18   
Data      $00,   $00      ' 19   
Data      $7A,   $5A      ' 1A zZ   
Data      $73,   $53      ' 1B sS   
Data      $61,   $41      ' 1C aA   
Data      $77,   $57      ' 1D wW   
Data      $32,   $40      ' 1E 2@   
Data      $A1,   $E1      ' 1F Windows 98 menu key (left side)   
Data      $00,   $00      ' 20    
Data      $63,   $43      ' 21 cC   
Data      $78,   $58      ' 22 xX   
Data      $64,   $44      ' 23 dD   
Data      $65,   $45      ' 24 eE   
Data      $34,   $24      ' 25 4$   
Data      $33,   $23      ' 26 3#   
Data      $A2,   $E2      ' 27 Windows 98 menu key (right side)   
Data      $00,   $00      ' 28   
Data      $20,   $20      ' 29 space   
Data      $76,   $56      ' 2A vV   
Data      $66,   $46      ' 2B fF   
Data      $74,   $54      ' 2C tT   
Data      $72,   $52      ' 2D rR   
Data      $35,   $25      ' 2E 5%   
Data      $A3,   $E3      ' 2F Windows 98 option key (right click, right side)   
Data      $00,   $00      ' 30   
Data      $6E,   $4E      ' 31 nN   
Data      $62,   $42      ' 32 bB   
Data      $68,   $48      ' 33 hH   
Data      $67,   $47      ' 34 gG   
Data      $79,   $59      ' 35 yY   
Data      $36,   $5E      ' 36 6^   
Data      $A4,   $E4      ' 37 Power Key    
Data      $00,   $00      ' 38   
Data      $00,   $00      ' 39   
Data      $6D,   $4D      ' 3A mM   
Data      $6A,   $4A      ' 3B jJ   
Data      $75,   $55      ' 3C uU   
Data      $37,   $26      ' 3D 7&   
Data      $38,   $2A      ' 3E 8*   
Data      $A5,   $E5      ' 3F Sleep Key   
Data      $00,   $00      ' 40   
Data      $2C,   $3C      ' 41 ,<   
Data      $6B,   $4B      ' 42 kK   
Data      $69,   $49      ' 43 iI   
Data      $6F,   $4F      ' 44 oO   
Data      $30,   $29      ' 45 0)   
Data      $39,   $28      ' 46 9(   
Data      $00,   $00      ' 47   
Data      $00,   $00      ' 48   
Data      $2E,   $3E      ' 49 .>   
Data      $2F,   $3F      ' 4A /?   
Data      $6C,   $4C      ' 4B lL   
Data      $3B,   $3A      ' 4C ':   
Data      $70,   $50      ' 4D pP   
Data      $2D,   $5F      ' 4E -_   
Data      $00,   $00      ' 4F   
Data      $00,   $00      ' 50   
Data      $00,   $00      ' 51   
Data      $27,   $22      ' 52 '"   
Data      $00,   $00      ' 53   
Data      $5B,   $7B      ' 54 [{   
Data      $3D,   $2B      ' 55 =+   
Data      $00,   $00      ' 56   
Data      $00,   $00      ' 57   
Data      $00,   $00      ' 58 caps   
Data      $00,   $00      ' 59 r shift   
Data      $0D,   $0D      ' 5A <Enter>   
Data      $5D,   $7D      ' 5B ]}   
Data      $00,   $00      ' 5C   
Data      $5C,   $7C      ' 5D \|   
Data      $A6,   $E6      ' 5E Wake Key   
Data      $00,   $00      ' 5F   
Data      $00,   $00      ' 60   
Data      $00,   $00      ' 61   
Data      $00,   $00      ' 62   
Data      $00,   $00      ' 63   
Data      $00,   $00      ' 64   
Data      $00,   $00      ' 65   
Data      $08,   $08      ' 66 bkspace   
Data      $00,   $00      ' 67   
Data      $00,   $00      ' 68   
Data      $31,   $91      ' 69 kp 1 {End}
Data      $2f,   $2f      ' 6A kp / converted from E04A in code   
Data      $34,   $94      ' 6B kp 4 {Left}   
Data      $37,   $97      ' 6C kp 7 {Home}   
Data      $00,   $00      ' 6D   
Data      $00,   $00      ' 6E   
Data      $00,   $00      ' 6F   
Data      $30,   $90      ' 70 kp 0 {Ins}   
Data      $2E,   $7F      ' 71 kp . {Del}   
Data      $32,   $92      ' 72 kp 2 {Down}   
Data      $35,   $95      ' 73 kp 5   
Data      $36,   $96      ' 74 kp 6 {Right}   
Data      $38,   $98      ' 75 kp 8 {Up}   
Data      $1B,   $1B      ' 76 esc   
Data      $00,   $00      ' 77 num lock   
Data      $8B,   $CB      ' 78 F11   
Data      $2B,   $2B      ' 79 kp +   
Data      $33,   $93      ' 7A kp 3 {PgDn}   
Data      $2D,   $2D      ' 7B kp -   
Data      $2A,   $2A      ' 7C kp *   
Data      $39,   $99      ' 7D kp 9 {PgUp}   
Data      $8D,   $CD      ' 7E scroll lock   
Data      $00,   $00      ' 7F

Dim cline As Byte
cline=0
Dim cln As Byte
cln=5
Dim b As Bit
Dim q As Word
Dim w[11] As Byte   
Dim tr[11] As Byte
Dim p As Byte
Dim o As Byte
Dim lky As Byte
Dim s As Bit
Dim c As Byte
Dim a As Byte
Dim nl As Byte
Dim sl As Byte
Dim ign As Byte
Dim pa As Byte
Dim tmx As Byte
Dim l As Byte
rs:
ign=1
q=0
b=0
p=0
o=0
c=0
s=0
sl=0
nl=0
pa=0
IRQ=0
OUT=0
If PCON>3 Then PCON=3
DelayMS 100
PIE1=0
PIE1.7=1
INTCON.7=1
INTCON.6=1
Enable
Cls
Print "Init "
doo:

If cbrp<>cbwp And q=0 Then
    If cbuf[cbrp]=1 Then
        Cls
        cline=0
        cln=0
    ElseIf cbuf[cbrp]=2 Then
        ZY=1
    ElseIf cbuf[cbrp]=$0D Then   
        If l<>$0D And l<>$0A Then GoSub clin
    ElseIf cbuf[cbrp]=$0A Then   
        If l<>$0D And l<>$0A Then GoSub clin
    ElseIf cbuf[cbrp]=8 Then     
        Dec cln
        If cln<0 And cline>0 Then
            Dec cline
            If cline=0 Then
                Print $FE , 2
            ElseIf cline=1 Then
                Print $FE, $C0
            ElseIf cline=2 Then
                Print $FE, $94
            EndIf
            For cln=0 To 18
                Print $FE, $14
            Next
            Print " "
        Else
            If cline>0 Or cln>0 Then Print $FE, $10, " ", $FE, $10
        EndIf
    ElseIf cbuf[cbrp]=7 Then
        For tmx=0 To 250
            DelayMS 1
            PORTA.5=1
            DelayMS 1
            PORTA.5=0
        Next
    ElseIf cbuf[cbrp]="{" Then
        'I2cin SDA, SCL, Control , Address , 0
       
        FLAGw = 2 : I2C_OUT[0] = 0 : I2C_OUT[1] = 0
        GoSub I2CTX
 
    ElseIf cbuf[cbrp]="}" Then
        'I2cIn SDA, SCL, Control , Address, ict ' Read the byte from the eeprom
        FLAGw = 1 : I2C_OUT[0] = 0   ' 1 Byte out, R/W = 0 because TX subroutine used
        GoSub I2CTXP
        Print DEC1 I2C_IN[0]
    Else
        If cln>19 Then GoSub clin
        Print cbuf[cbrp]
        Inc cln
    End If
   
    l=cbuf[cbrp]
    Inc cbrp
   
    If cbrp>127 Then cbrp=0
End If
'If ACK=1 Then
'IRQ=0
'If MODE=0 Then OUT=0
'EndIf
'If RST=1 Then
'GoSub resx
'GoTo rs
'EndIf
If CLK=1 Then b=1
    If b=1 And CLK=0 Then
        b=0
        Inc q
        If q>1 And q<10 Then
            w[q]=DAT
        EndIf
        If q=10 Then pa=DAT
        If q=11 Then
            o=0
            For q=9 To 2 Step -1
                o=o<<1
                o=o+w[q]
                If w[q]=1 Then pa=1-pa
                w[q]=0
            Next
            If pa=0 Then
                GoSub rese
                o=0
            EndIf
        If ign=0 Then
            If o=225 Then ign=8
            If o=224 Then ign=1
        EndIf
        If ign>0 Then
            Dec ign
            o=0
        EndIf
       
        If lky=240 And o<>240 Then
            If MODE=1 Then OUT=0
            If o=88 Then
                c=1-c
                GoSub leds
            EndIf 
            If o=119 Then
                nl=1-nl
                GoSub leds
            EndIf 
            If o=126 Then
                sl=1-sl
                GoSub leds
            EndIf 
            If o=89 Or o=18 Then
                s=0
            EndIf
            o=0
        EndIf     
        If o=89 Or o=18 Then s=1
       
        'If o=102 Then Cls
        If o>0 And o<128 Then
            'a=0
            'If s=1 Then a=1
            o=(o*2)+s
            Restore o
            Read o
            If ZY=1 Then
                If o="Z" Then o="Y"
                ElseIf o="Y" Then o="Z"
                If o="z" Then o="y"
                ElseIf o="y" Then o="z"
            EndIf
            If s=0 Then
                If c=1 And o>96 And o<123 Then o=o-32
            Else
                If c=1 And o>64 And o<91 Then o=o+32
            End If
            OUT=o
            o=0
        EndIf
        lky=o
        q=0
    EndIf
EndIf


GoTo doo


rese:
tr[0]=0
tr[1]=0
tr[2]=1
tr[3]=1
tr[4]=1
tr[5]=1
tr[6]=1
tr[7]=1
tr[8]=1
tr[9]=0
tr[10]=1
GoSub tra
Return

resx:
tr[0]=0
tr[1]=1
tr[2]=1
tr[3]=1
tr[4]=1
tr[5]=1
tr[6]=1
tr[7]=1
tr[8]=1
tr[9]=1
tr[10]=1
GoSub tra
Return

leds:
tr[0]=0
tr[1]=1
tr[2]=0
tr[3]=1
tr[4]=1
tr[5]=0
tr[6]=1
tr[7]=1
tr[8]=1
tr[9]=1
tr[10]=1
GoSub tra
tr[0]=0
tr[1]=sl
tr[2]=nl
tr[3]=c
tr[4]=0
tr[5]=0
tr[6]=0
tr[7]=0
tr[8]=0
tr[9]=c+nl+sl
If tr[9]>1 Then tr[9]=tr[9]-2
tr[9]=1-tr[9]
tr[10]=1
GoSub tra
Return

tra:
Output CLK
Output DAT
CLK=0
DAT=1
DelayUS 200
CLK=1
DAT=0
Input CLK
q=1
While q <= 11
If CLK=1 Then b=1
If b=1 And CLK=0 Then
b=0
DAT=tr[q]
tr[q]=0
Inc q
EndIf
Wend
Input CLK
Input DAT
DelayUS 200
Return 

Sio:
Context SAVE
PIR1.7=0
If OBF=0 Then
PORTD=0
Else
cbuf[cbwp]=PORTD
Inc cbwp
If cbwp>127 Then cbwp=0
EndIf
Context Restore
retfie

clin:
    If cline=0 Then
        Inc cline
        Print $FE , $C0
    ElseIf cline=1 Then
        Inc cline
        Print $FE, $94
    ElseIf cline=2 Then
        Inc cline
        Print $FE, $D4
    Else
        Print $FE, 1
        cline=0
    EndIf
    cln=0
Return 

I2CTX:                   ' Transmit I2C Routine
    GoSub I2C_Start      ' Issue Start Condition
    RWw = 0               ' “Write” command
    GoSub Set_ADDR       ' Send Address from variable ADDR
    For Nw = 1 To FLAGw    ' Shifts out byte[0]..[1]… for number in FLAG times
        SHOut SDA, SCL, 1, [I2C_OUT[Nw-1]\8]
        SHIn  SDA, SCL, 0, [I2C_ACK\1]
    Next
    GoSub I2C_Stop       ' Issue Stop Command
    Return
 
I2CTXP:                   ' Transmit I2C Routine
    GoSub I2C_Start      ' Issue Start Condition
    RWw = 0               ' “Write” command
    SHOut SDA, SCL, 1, [ADDR\8,RWw\1]
    SHIn  SDA, SCL, 0, [I2C_ACK\1]       ' Send Address from variable ADDR
   
        SHOut SDA, SCL, 1, [I2C_OUT[0]\8]
        SHIn  SDA, SCL, 0, [I2C_ACK\1]
   
    RWw = 1               ' “Read” command
    GoSub I2C_Start
    SHOut SDA, SCL, 1, [ADDR\8,RWw\1]
    SHIn  SDA, SCL, 0, [I2C_ACK\1]
   
    SHIn  SDA, SCL, 0, [I2C_IN[0]\8]' *** Send last byte with NACK ***
    SHOut SDA, SCL, 1, [%1\1]
    GoSub I2C_Stop     
    Return
 
I2CRX:                   ' Receive I2C Routine
    GoSub I2C_Start
    RWw = 1               ' “Read” command
    GoSub Set_ADDR
    If FLAGw >= 2 Then    ' If there is more then 1 byte, send all but last, then ACK
        For Nw = 1 To (FLAGw - 1)
          SHIn  SDA, SCL, 0, [I2C_IN[Nw-1]\8]
          SHOut SDA, SCL, 1, [%0\1]
        Next
    EndIf
    SHIn  SDA, SCL, 0, [I2C_IN[FLAGw-1]\8]' *** Send last byte with NACK ***
    SHOut SDA, SCL, 1, [%1\1]
    GoSub I2C_Stop                          ' Issue Stop command
    Return
 
Set_ADDR:                                   ' Send Address of device from Var ADDR
    SHOut SDA, SCL, 1, [ADDR >> 1\7,RWw\1]' Shifts ADDR bits over, adds on R/W bit
    SHIn  SDA, SCL, 0, [I2C_ACK\1]       ' Receives ACK
    Return
 
I2C_Start:           ' Start Condition
    High SDA
    High SCL
    Low SDA
    Low SCL
    Return
 
I2C_Stop:            ' Stop Condition
    Low SDA
    High SCL
    High SDA
    DelayMS 1
    Return


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 10, 2012 10:28 am 
Offline
User avatar

Joined: Sat Dec 01, 2012 10:31 pm
Posts: 16
Location: England.
neat, so in effect you could swap out the LCD library and replace it with a Serial library and then use that directly to your SBC serial port.
Like yourself I also haven`t added data for the CRTL key on mine, so CTRL-C (break) has to be done by hitting the reset switch :)
and although it`s a fairly trivial matter to add this, I got a bit carried away with other parts of the project and didn`t get around to it (yet).

Thanks for the Proton mention, it looks like a variant of Basic, and I only use Basic, so I`ll certainly look into this, esp if it`s my Favorite price (Free).
it`s also nice to see that you`re using the 877, I sell 877 Kits that my daughter and I made, it`s a great little chip, the 18F4685 is like it`s Much bigger brother (48K) but still pin for pin compatible.
if I remember correctly off the top of my head, the memory sizes for the 877 pinout go something like:

16F877
18F452(0)
18F4620
and the 18F4685
the 18F4550 will also fit, but one of the port C pins is 3.3V out instead of an I/O.

Just in case you ever wanted to Add more to your above code and worried about running out of Mem ;)

_________________
Also on Twitter as "YT2095".


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 10, 2012 8:59 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
Quote:
CTRL-C (break) has to be done by hitting the reset switch

What code the mcu needs to send to EhBasic to register as break?


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 10, 2012 9:22 pm 
Offline
User avatar

Joined: Sat Dec 01, 2012 10:31 pm
Posts: 16
Location: England.
I`m unfamilliar with EhBasic, but yes, it`s the Break code for many versions of basic, and I can`t use it because I forgot to add the CRTL keys code in library, I`ll get around to though.
in fact I`m pretty sure someone did write a better Keyboard library for GCBasic already, I`ll have to find it and use that, no point trying to reinvent the wheel ;)

_________________
Also on Twitter as "YT2095".


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 10, 2012 10:09 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
What's the best way to manifest the receiving a "Break Key"?

Back In The Day, Break actually meant something, it's a signal status of RS-232 (and different from just a character with a value of 0). In that sense, a Serial In has 257 values, 0-255 for the byte and Break.

You can use ^C, but do you just set a flag in the BIOS when it's hit?

I recall some poor handling of things like ^C where they were reading the keyboard and looking at the first character. But if you typed something first, the type ahead would be buffered and the ^C never seen (since it's blocked by normal typing). So, simply looking at the keyboard (at least the keyboard buffer) isn't really the solution either, it needs to be lower level and part of the underlying system I think.

Then the question becomes, if the BIOS is looking for a specific key, (^C say) and then setting a flag, does the BIOS then consume the key, or leave it in the keyboard buffer?

Arguably in your program, where you test the global interrupt flag, you can reset the buffer when you detect the break key to keep any extraneous characters from being entered after you have aborted. Or, not, as you wish. If you let the buffer keep the character then your code can simply choose to not check the interrupt flag, thus letting you accept all characters from the I/O device (vs all but 1, the break key).

The Atari had a hard wired BREAK key which was tied to an actual interrupt. I could see the keyboard handler having a vector that it could call when it detected the magic character, but I think that's actually less useful for most applications. The handling can still have the vector and simply use the in built handler to set the Well Known status register, but the user could override that for their own purposes. The vectored routine can even be an interrupt routine, since ideally, keyboard handling is interrupt driven anyway.

So, anyway, seems to me a break handler would best be done by having the console driver detect the Magic Key, and set a flag, along with service routines to reset the status, setting the character to look for, and enabling/disabling the detection of it. With an overridable interrupt handler, the host program can clean up the stack and JMP to wherever it wanted and then regular code would not have to poll for the break event. But for things like interpreters, it's not arduous to monitor it in the core run loop.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 11, 2012 6:52 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8505
Location: Midwestern USA
whartung wrote:
What's the best way to manifest the receiving a "Break Key"?

Back In The Day, Break actually meant something, it's a signal status of RS-232 (and different from just a character with a value of 0). In that sense, a Serial In has 257 values, 0-255 for the byte and Break.

Way Back in the Day (back when dinosaurs operated computers) a received break was often used by an operating system to change the baud rate. For a long time, modems could not automatically train in on a specific baud rate. The caller called at whatever speed his modem could support and if the host system was operating at a different baud rate, the caller would do something to cause his modem to send a break, usually by hitting the break key on his terminal. That would tell the host to try a different baud rate. If the new baud rate still wasn't right, the caller would have to send yet another break, hoping that the host would get it right. The gettydefs table of some UNIX-like operating systems have definitions that configure the serial interface to different baud rates each time a break is received.

Quote:
Then the question becomes, if the BIOS is looking for a specific key, (^C say) and then setting a flag, does the BIOS then consume the key, or leave it in the keyboard buffer?

I was playing around with this in POC V1.1 and what I did was cause the DUART to interrupt the MPU in the event I hit the break key on the console terminal (WYSE 60 with an ASCII keyboard). The DUART has an interrupt bit for a received break, so I could use it to halt a runaway program, assuming it didn't take down the whole system. I have since then rigged up NMI to do this and took the break IRQ out of the DUART setup parameters. Hitting the break key now does nothing.

Logically, the PC keyboard's break key should be wired to produce some sort of interrupt which would set a flag that the foreground process could poll. I don't think you'd want the break interrupt literally halting the foreground, since it could happen at an inconvenient time (e.g., during file I/O).

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: