AT/PS2 Keybord - PIC Interface? - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 41 to 74 of 74
  1. #41
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Reading A Ps/2 Keyboard.

    I JUST FOUND THIS SITE VERY USEFUL (PDS CODE) AND THE CODE WORKED WITH ME. i COULD DECODE THE PS/2 KEYBOARD ATTACHED TO THE PIC ON THE LCD.

    SORRY FOR PUTTING UP A PDS CODE. CAN ANYONE CONVERT IT FOR PBP. IT HAS A LOT OF ASM, WONDER WHY ?

    http://users.picbasic.org/Howto/PC_k...c_keyboard.htm

    REGARDS

  2. #42
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Good suggestion.

    Quote Originally Posted by keithdoxey View Post
    WOW!!!!

    Whilst a few of us here might might have slightly impaired hearing either due to geting older or working in nightclubs...or both... I dont believe we are totally deaf yet!!!

    Please stop shouting or buy a keyboard that also has lower case letters on it as well !!!!
    I think i need to take your suggestion and shut my mouth about it.

    regards

  3. #43
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by charudatt View Post
    I JUST FOUND THIS SITE VERY USEFUL (PDS CODE) AND THE CODE WORKED WITH ME. i COULD DECODE THE PS/2 KEYBOARD ATTACHED TO THE PIC ON THE LCD. SORRY FOR PUTTING UP A PDS CODE. CAN ANYONE CONVERT IT FOR PBP. IT HAS A LOT OF ASM, WONDER WHY ? http://users.picbasic.org/Howto/PC_k...c_keyboard.htm
    REGARDS
    Why don't you try converting it over. Then if/when it doesn't work, we'll help you figure out why it doesn't work.

  4. #44
    Join Date
    Nov 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Hi guys,

    I was wondering if someone can help me out here on a simple task.
    I've been learning a lot by reading about sending data to a keyboard's PS/2 port, but I am unable to send a simple letter and have it show up in notepad.exe on the host computer.

    I know the following: data sent must have Start Bit = 0, Scancode (LSB First), Odd Parity, Stop Bit = 1.

    Now, I don't care about keyboard initialization, because I will be booting up the PC with a normal keyboard attached, then swapping out the keyboard with my device.

    All I want to do is send the letter 'q' ($15).

    I am doing so by sending q (0+$51+0+1), then the release code (0+$0F+1+1), then q again (0+$51+0+1).

    However, I am not getting anything on the host side of things.

    Here is my code:




    Code:
    ; PS2SendCode          
    ;               
    ;                                     PIC16F648A                 
    ;                         _________________  _______________          
    ;                       1|RA2/AN2/VREF               RA1/AN1|18
    ;                       2|RA3/AN3/CMP1               RA0/AN0|17 
    ;                       3|RA4/TOCKI/CMP2      RA7/OSC1/CLKIN|16     
    ;              VPP ---> 4|RA5/MCLR/VPP       RA6/OSC2/CLKOUT|15                            
    ;                   Gnd 5|Vss                            Vdd|14 +5                            
    ;                       6|RB0/INT              RB7/T1OSI/PGD|13 <--- PGD            
    ;                       7|RB1/RX/DT      RB6/T1OSO/T1CKI/PGC|12 <--- PGC                    
    ;                       8|RB2/TX/CK                      RB5|11 <--> PS2DATA
    ;      PUSH BUTTON ---> 9|RB3/CCP1                   RB4/PGM|10 <--- PS2CLK _|¯|_|¯|_|¯|_|¯|_ 
    ;                         ----------------------------------           
    ;                       
    ;===============================================================================
    ;                             Keyboard to Host Protocol
    ;             ___    _   _   _   _   _   _   _   _   _   _   _   _   ___
    ;       CLOCK    |__| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_|
    ;
    ;       DATA       |  S | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | P | E |
    ;
    ;          S = start bit = 0    P = odd parity   E = stop bit = 1
    ;                      data valid on falling edge of clock
    ;===============================================================================
    
    
    @                 errorlevel  -223,-207,-306               ; Suppress useless messages
    @                 LIST   P=PIC16F648A
    @                 __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF & _BODEN_OFF & _PWRTE_OFF & _LVP_OFF
    
    ;Using 4MHz oscillator
    define          OSC 4
    ;DEFINE SHIFT_PAUSEUS 43
    
                    PortB = 0            'Clear Port B
                    INTCON = 0           'Interrupts Off
                    CMCON = %00000111    'Disable Comparators
                    OPTION_REG.7 = 0     'Enable Port B Weak Pull-Ups
    
    BitCnt          VAR BYTE
    KBTimeout       VAR BYTE
    ScanCode        VAR Word
    Parity          Var BYTE
    StartButton     Var PortB.3
    PS2Clk          var PortB.4          '0
    PS2Dat          var PortB.5          '0
                    TRISB = %11111111    'Set PORTB pins direction to input
    
    Start:          pause 500
                                    
                    if startbutton = 0 then: goSUB StartSend
    
                    goto start
    
    StartSend:                                       
                    'SEND Q ($15 LSB FIRST)
                    Parity = 1                          'Odd parity
                    scancode.0 = 0
                    Gosub sendbit                       'send START BIT
                    scancode = %00010101                'send 'q'
                    For bitcnt = 1 To 8                 'set for 8 data bits
                        Gosub sendbit                   'send DATA BIT
                        If scancode.0 = 1 Then: parity = parity + 1
                    scancode = scancode >> 1            'shift out next bit
                    Next bitcnt
                    scancode.0 = parity.0
                    Gosub sendbit                       'send PARITY BIT
                    scancode.0 = 1
                    Gosub sendbit                       'send STOP BIT
    
                    'SEND RELEASE ($F0 LSB FIRST)
                    Parity = 1                          'Odd parity
                    scancode.0 = 0
                    Gosub sendbit                       'send START BIT
                    scancode = %11110000                'send '$F0'
                    For bitcnt = 1 To 8                 'set for 8 data bits
                        Gosub sendbit                   'send DATA BIT
                        If scancode.0 = 1 Then: parity = parity + 1
                        scancode = scancode >> 1        'shift out next bit
                    Next bitcnt
                    scancode.0 = parity.0
                    Gosub sendbit                       'send PARITY BIT
                    scancode.0 = 1
                    Gosub sendbit                       'send STOP BIT
    
                    'SEND Q ($15 LSB FIRST)
                    Parity = 1                          'Odd parity
                    scancode.0 = 0
                    Gosub sendbit                       'send START BIT
                    scancode = %00010101                'send 'q'
                    For bitcnt = 1 To 8                 'set for 8 data bits
                        Gosub sendbit                   'send DATA BIT
                        If scancode.0 = 1 Then: parity = parity + 1
                        scancode = scancode >> 1        'shift out next bit
                    Next bitcnt
                    scancode.0 = parity.0
                    Gosub sendbit                       'send PARITY BIT
                    scancode.0 = 1
                    Gosub sendbit                       'send STOP BIT
            
                    Return
         
    SendBit:
            'Looking for keyboard clock and data line to go high, then send data bit to it!
            ;If NOT(PS2Clk = 1 AND PS2Dat = 1) Then sendbit  'loop until clock line goes low
            PS2Dat = scancode.0                             'send data bit
            return
    Any advice appreciated.

  5. #45
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Take a look at post #6 at
    http://www.picbasic.co.uk/forum/showthread.php?t=7962

    Also, I am not sure about the way you control the Clock line in your code.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #46
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Yeah, your code seems to indicate that you are waiting for the clock line to do something?

    Your device must generate the clock in this case.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #47
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Ok, I misunderstood.

    I now realized that you are SENDING data TO KB;
    Not reading from it.

    Sorry about that.

    ------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  8. #48
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    rookie11, I don't think this code will ever work. Where are the ENDIF commands to terminate the IF statements?

    Dave Purola,
    N8NTA

  9. #49
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    rookie11, I don't think this code will ever work. Where are the ENDIF commands to terminate the IF statements?

    Dave Purola,
    N8NTA
    One line If/Then statements....don't need an ENDIF....

    If this=0 then gosub dothis : that=1 : goto something

    ...valid statement
    If this is zero, then gosub dothis, set that to 1, then goto something.

    But that colon following the THEN in the code a few posts back looks a bit strange to me...
    And I know colons!

  10. #50
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    skimask , Look before you leap.... Look at where the colon lies........

    Dave Purola.
    N8NTA

  11. #51
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    skimask , Look before you leap.... Look at where the colon lies........

    Dave Purola.
    N8NTA
    Well, I was talking about the code attached above. He has this line (along with another that's the same way):

    If scancode.0 = 1 Then: parity = parity + 1
    ----------------------^

    I don't know how that'll compile, if it will compile good and not cause an error, if it'll work as written, or what will happen. It just doesn't look right to me, that's all...

    And I'm always keeping track of where my colon's lie...

  12. #52
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    skimask, The way I interpret a colon is to terminate a line of code and, allow the start of another command string to be placed on the same line. If this is the case then all of his IF/THEN statements should have and ending ENDIF command. I have not tried this as I never write code in this fashion. It is much to confusing and hard to follow the flow... Have you ever tried this format? If it works then GREAT...

    Dave Purola,
    N8NTA

  13. #53
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    It is much to confusing and hard to follow the flow... Have you ever tried this format? If it works then GREAT...
    I guess I use whatever fits/works and takes up as few actual lines on the screen.
    As far as being confusing, well, I usually don't write code for other folks (reference the High Colonic Master ), and if I wrote it for myself, then I'd better be able to follow it! And as long as a guy keeps a constant format...well, that should be all ya need...
    But, I'm going to play with the If/Then colon format thing tonight when I get home and see what happens...

  14. #54
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    Are you guys looking to emulate a PS/2 keyboard or get data from a PS/2 keyboard?

    I have pure PBP code for both if you need it.

  15. #55
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by PJALM View Post
    Are you guys looking to emulate a PS/2 keyboard or get data from a PS/2 keyboard?

    I have pure PBP code for both if you need it.
    May I see the emulation code, then?
    IF, of course, it is responding to the system commands ??


    ------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  16. #56
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    May I see the emulation code, then?
    IF, of course, it is responding to the system commands ??
    ------------
    I second that commotion...no sense reinventing the wheel...
    It's the responding back to the PC bit that gets me...

  17. #57
    Join Date
    Sep 2006
    Location
    Venezuela - Caracas
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    PJALM's

    is possible upload the code?

    i use http://www.picbasic.co.uk/forum/arch...hp/t-2736.html but not work leds

    many thanks
    ..: Don't worry, be happy :..

  18. #58
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Where have I seen that thread before? Guess I'll go to Post #1 and read through it again and try to figure it out. (i.e. endless loop)

  19. #59
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I second that commotion...no sense reinventing the wheel...
    It's the responding back to the PC bit that gets me...
    Ski, I did not quite understand what you meant but,
    PC (system) can terminate the communication while KB is sending data to it AND send system commands to it to have it do something; turn on/off status leds, resend last byte etc...

    The thing is to detect this termination thingie during an active transmission.

    This is what I meant.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  20. #60
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Ski, I did not quite understand what you meant but,
    PC (system) can terminate the communication while KB is sending data to it AND send system commands to it to have it do something; turn on/off status leds, resend last byte etc...
    The thing is to detect this termination thingie during an active transmission.
    This is what I meant.
    Ok, I was talking about the initial comm's to the keyboard when the PC powers up. It's been discussed in a couple of other threads somewhere.

  21. #61
    gatlartech's Avatar
    gatlartech Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by PJALM View Post
    Are you guys looking to emulate a PS/2 keyboard or get data from a PS/2 keyboard?

    I have pure PBP code for both if you need it.

    I am interested in code to emulate a PS/2 keyboard using a 16f88 interfacing to an embedded PC. Is it possible to view your PBP code?

  22. #62
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default PBP code for PS/2 emulation

    showed the carrot and now missing in action.

    Where is the guy with the PBP code ?

  23. #63
    Join Date
    Mar 2005
    Location
    CROATIA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    i have to do 4x4 scan key to ps2 intf. with (one time) programmable keys, numeric part + some fonction key ie. P, A, X, Y...
    but I'm not shure is it a lot of work in that system area,: tx ack, rx sys requests, init in PCstart, and others, if there is a way to put paralel with old kb board to do that portion, (if I dont hawe to switch betwen) then, sems to be easy ?

  24. #64
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    PS2 emulation is harder than it seems. Maybe possible to fit a PIC in parallel of an existing controller, but i feel some potential bit collision one day or another.

    I've done it with a single PIC, and frankly... enough time spent and wasted on it to hate it now
    Last edited by mister_e; - 4th May 2008 at 19:31.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  25. #65


    Did you find this post helpful? Yes | No

    Default

    I've seen keyboard emulators in different gaming forums (mostly mame related), where it IS put in parallel with the keyboard.

    anyways, I came across this function/macro/whatever for reading a ps/2 keyboard in great cow basic. says it's free and ok to copy sooo...


    Code:
    '    PS/2 keyboard/mouse routines for Great Cow BASIC
    '    Copyright (C) 2006 Hugh Considine
    
    '    This library is free software; you can redistribute it and/or
    '    modify it under the terms of the GNU Lesser General Public
    '    License as published by the Free Software Foundation; either
    '    version 2.1 of the License, or (at your option) any later version.
    
    '    This library is distributed in the hope that it will be useful,
    '    but WITHOUT ANY WARRANTY; without even the implied warranty of
    '    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    '    Lesser General Public License for more details.
    
    '    You should have received a copy of the GNU Lesser General Public
    '    License along with this library; if not, write to the Free Software
    '    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    
    '********************************************************************************
    'IMPORTANT:
    'THIS FILE IS ESSENTIAL FOR SOME OF THE COMMANDS IN GCBASIC. DO NOT ALTER THIS FILE
    'UNLESS YOU KNOW WHAT YOU ARE DOING. CHANGING THIS FILE COULD RENDER SOME GCBASIC
    'COMMANDS UNUSABLE!
    '********************************************************************************
    
    #define PS2Data SysTemp.0 'Set to data pin
    #define PS2Clock SysTemp.0 'Set to clock pin
    
    #startup InitPS2
    
    'Initialise
    sub InitPS2
     DIR PS2Clock IN
     DIR PS2Data IN
     KeyShift = 0
     MouseX = 0
     MouseY = 0
    end sub
    
    'Return ASCII value of input key
    function INKEY
     'Initialise, and get key scan code
     INKEY = 0
     ScanCode = PS2ReadByte
     if ScanCode = 0 then exit function
    
     '2-byte key?
     if ScanCode = 0xE0 then
      do while INKEY = 0
       INKEY = PS2ReadByte
      loop
      INKEY = INKEY OR 128
     end if
    
     'Shift/Capslock
     if ScanCode = 0x12 or ScanCode = 0x59 then KeyShift = 1: exit function
     if ScanCode = 0x58 then 
      if KeyShift = 2 then KeyShift = 0: exit function
      KeyShift = 2
      exit function
     end if
    
     'Translate scan code to ASCII
     
     'Control Chars
     if ScanCode = 0x5A then INKEY = 13	'Enter
     if ScanCode = 0x66 then INKEY = 8	'Backspace
     if ScanCode = 0x76 then INKEY = 27	'Esc
     if ScanCode = 0x29 then INKEY = 32	'Space
    
     'Arrows
     
    
     'Numbers
     if ScanCode = 0x45 then INKEY = 48
     if ScanCode = 0x16 then INKEY = 49
     if ScanCode = 0x1E then INKEY = 50
     if ScanCode = 0x26 then INKEY = 51
     if ScanCode = 0x25 then INKEY = 52
     if ScanCode = 0x2E then INKEY = 53
     if ScanCode = 0x36 then INKEY = 54
     if ScanCode = 0x3D then INKEY = 55
     if ScanCode = 0x3E then INKEY = 56
     if ScanCode = 0x46 then INKEY = 57
    
     'Letters
     if ScanCode = 0x1C then INKEY = 65 'A
     if ScanCode = 0x32 then INKEY = 66
     if ScanCode = 0x21 then INKEY = 67 'C
     if ScanCode = 0x23 then INKEY = 68
     if ScanCode = 0x24 then INKEY = 69 'E
     if ScanCode = 0x2B then INKEY = 70
     if ScanCode = 0x34 then INKEY = 71 'G
     if ScanCode = 0x33 then INKEY = 72
     if ScanCode = 0x43 then INKEY = 73 'I
     if ScanCode = 0x3B then INKEY = 74
     if ScanCode = 0x42 then INKEY = 75 'K
     if ScanCode = 0x4B then INKEY = 76
     if ScanCode = 0x3A then INKEY = 77 'M
     if ScanCode = 0x31 then INKEY = 78
     if ScanCode = 0x44 then INKEY = 79 'O
     if ScanCode = 0x4D then INKEY = 80
     if ScanCode = 0x15 then INKEY = 81 'Q
     if ScanCode = 0x2D then INKEY = 82
     if ScanCode = 0x1B then INKEY = 83 'S
     if ScanCode = 0x2C then INKEY = 84
     if ScanCode = 0x3C then INKEY = 85 'U
     if ScanCode = 0x2A then INKEY = 86
     if ScanCode = 0x1D then INKEY = 87 'W
     if ScanCode = 0x22 then INKEY = 88
     if ScanCode = 0x35 then INKEY = 89 'Y
     if ScanCode = 0x1A then INKEY = 90 'Z
    
     if INKEY >= 65 and INKEY <= 90 and KeyShift = 0 then INKEY += 32
    
     'Symbols
     if ScanCode = 0x0E then INKEY = 96 '`
     if ScanCode = 0x4E then INKEY = 45 '-
     if ScanCode = 0x55 then INKEY = 61 '=
     if ScanCode = 0x5D then INKEY = 92 '\
     if ScanCode = 0x4c then INKEY = 59 ';
     if ScanCode = 0x52 then INKEY = 39 ''
     if ScanCode = 0x41 then INKEY = 44 ',
     if ScanCode = 0x49 then INKEY = 46 '.
     if ScanCode = 0x4A then INKEY = 47 '/
    
     if KeyShift = 1 then KeyShift = 0
    
    end function
    
    function PS2ReadByte
     PS2ReadByte = 0
     if PS2Clock ON THEN exit function
    
     'Start Bit
     wait until PS2Clock OFF
     if PS2Data ON then exit function
     wait until PS2Clock ON
     
     '8 data bits
     For PS2Bit = 1 to 8
      wait until PS2Clock OFF 
      set STATUS.C OFF
      if PS2Data ON then set STATUS.C ON
      ROTATE PS2ReadByte RIGHT
      wait until PS2Clock ON
     next
    
     'Parity
      wait until PS2Clock OFF
      wait until PS2Clock ON
    
     'End
      wait until PS2Clock OFF
      wait until PS2Clock ON
    end function
    
    sub PS2WriteByte (PS2Byte) #NR
    
     'Take control
     dir PS2Clock Out
     set PS2Clock Off
     wait 12 10us
     dir PS2Data Out
     set PS2Data Off
     dir PS2Clock In
    
     'Start Bit
     wait until PS2Clock on
     wait until PS2Clock off
    
     PS2Parity = 0
     
     '8 data bits
     For PS2Bit = 1 to 8
      if PS2Byte.0 Off then Set PS2Data off
      if PS2Byte.0 On then Set PS2Data on: PS2Parity += 1
      ROTATE PS2ReadByte RIGHT
      wait until PS2Clock ON
      wait until PS2Clock OFF
     next
    
     'Parity
     if PS2Parity.0 off then Set PS2Data on  
     if PS2Parity.0 on then Set PS2Data off
     wait until PS2Clock ON
     wait until PS2Clock OFF
    
     'Stop
     set PS2Data On
     wait until PS2Clock ON
     wait until PS2Clock OFF
    
     'Ack
      Set PS2Data Off
      wait until PS2Clock ON
      dir PS2Data in
     
     wait 100 10us
    
    end sub
    don't know if it'll do anyone any good, but....

  26. #66
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Thumbs up Thanks Michael

    Hi Michael,

    I used your routine and it saved my life. Works like a breeze. Thanks for the great job and sharing it on this forum..
    Regards

    Sougata

  27. #67
    Join Date
    Mar 2006
    Posts
    41


    Did you find this post helpful? Yes | No

    Smile Routine

    Hi Sougata:
    Good day Bro, Can you share with me the routine?
    Ryan

  28. #68
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default The code is right in this thread

    Hi,

    The code is right in this thread as a zip attachment. I used it along with DT's Interrupt system and it worked fine.
    Regards

    Sougata

  29. #69
    Join Date
    Jan 2009
    Location
    Delaware
    Posts
    19


    Did you find this post helpful? Yes | No

    Default PS/2 to 18F4620 timing issues with mytekcontrols code?

    Hello!

    I have implemented the wonderful code PS/2 keyboard code from mytekcontrols in my PIC18F4620. It will only work if I set
    TOcntDLY CON to a value of 100 (originally set to 10 per mytekcontrols).

    Furthermore, if I hit and hold any of the these three keys (Caps Lock, Num Lock, or Scroll Lock), there is no response from the keyboard LEDs and the program just hangs. These keys will work if I hit them VERY quickly (less than .1 second - just hit with a glancing blow).

    Everything else works as it should (with the CON change above).

    Is this a big timing issue for me? Settings when programming?

    Reference:
    PIC 18F4620
    Internal OSC at 8Mhz
    OSCCON = %01110010
    BUT even with an external 20Mhz oscillator, same performance, still hangs!

    I sense severe timing issues. I will welcome all suggestions with regard to fixing this code for me.

    Thank you to all,
    Bob Pigford
    Newark, Delaware

  30. #70
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default May not be

    Hi,

    I used it on a 40MHz oscillator and did not have any issue. However the following may be considered:

    1. Allow enough time (2 seconds or more is safe) before calling the PS2init routine. Your keyboard needs this to boot-up. Indicated by all three LEDs flashing and going off.

    2. The characters are stored using interrupts but the interrupts are re-enabled only when parse it. This may cause the keyboards internal buffer to be overwhelmed.
    Regards

    Sougata

  31. #71
    Join Date
    Jan 2009
    Location
    Delaware
    Posts
    19


    Did you find this post helpful? Yes | No

    Default PS/2 to 18F4620 timing issues with mytekcontrols code?

    Thank you sougata,

    Quote Originally Posted by sougata View Post
    Hi,

    I used it on a 40MHz oscillator and did not have any issue. However the following may be considered:

    1. Allow enough time (2 seconds or more is safe) before calling the PS2init routine. Your keyboard needs this to boot-up. Indicated by all three LEDs flashing and going off.

    2. The characters are stored using interrupts but the interrupts are re-enabled only when parse it. This may cause the keyboards internal buffer to be overwhelmed.
    I did allow enough time for the keyboard to start. I see the LEDs flash, so I think that is not the issue.

    I will follow you suggestion and look into the buffer situation. I will also order a 40mhz oscillator just to be sure.

    I will report back on my progress.

    Thank you again,
    Bob Pigford
    Newark, Delaware, USA

  32. #72
    Join Date
    Jan 2009
    Location
    Delaware
    Posts
    19


    Did you find this post helpful? Yes | No

    Default PS/2 to 18F4620 timing issues isolated to "putkey" routine

    Quote Originally Posted by BobPigford View Post
    Thank you sougata,



    I did allow enough time for the keyboard to start. I see the LEDs flash, so I think that is not the issue.

    I will follow you suggestion and look into the buffer situation. I will also order a 40mhz oscillator just to be sure.

    I will report back on my progress.

    Thank you again,
    Bob Pigford
    Newark, Delaware, USA
    I just isolated the issue! If I eliminate any output going TO the keyboard, everything works just fine! I disabled the "putkey" routine buy placing a "RETURN" immediately after the beginning of the routine.

    Even with the internal oscillator at 8mhz, it all works very well (even with "TOcntDLY set back to 10)! I can live without seeing the LEDs on the keyboard for now. When my 40mhz oscillator arrives, it will try it again and report back.

    Regards,
    Bob

  33. #73
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Use HSPLL

    Hi,

    Every PIC18 has got a x4 HSPLL oscillator mode. So you can use an external 10MHz crystal to effectively get 40 MHz Fosc. For internal 8MHz you need to configure osccon to enable HSPLL and get 8 x 4 = 32MHz from the internal oscillator.
    Regards

    Sougata

  34. #74
    Join Date
    Jan 2009
    Location
    Delaware
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Will try HSPLL

    Quote Originally Posted by sougata View Post
    Hi,

    Every PIC18 has got a x4 HSPLL oscillator mode. So you can use an external 10MHz crystal to effectively get 40 MHz Fosc. For internal 8MHz you need to configure osccon to enable HSPLL and get 8 x 4 = 32MHz from the internal oscillator.
    Thank you Sougata. I will give this a try and report back. And thank you for teaching me about HSPLL.
    Regards,
    Bob

Similar Threads

  1. MXcom "C-BUS" interface to PIC question
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st May 2014, 04:59
  2. Interface a pic with a Iphone/Itouch
    By Luckyborg in forum General
    Replies: 1
    Last Post: - 6th May 2009, 17:02
  3. 4 pin 4 x 4 keypad interface using pic basic pro
    By dunlao_john in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th January 2009, 06:21
  4. USB Interface using PIC
    By Tissy in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 22nd May 2006, 17:04
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts