PDA

View Full Version : 16f877 and ps/2 keyboard error???



boraciner
- 4th July 2009, 08:58
Hi! I have been trying to make an interface between 16f877 and ps/2 keyboard but although I have connected the data and clk pins to PB.7 and PB.6 , I cannot see anything on my glcd.
Should I connect these pins with any pullup resistors from 5V or what shoud I do ??
I'm writing my codes below.. Pls help me!
Thans A Lot....




Include "PROTON18_452.BAS"
Device 16F877
WARNINGS = OFF


TRISB=%0110000
Symbol Giris PORTB.6
Symbol Clk PORTB.5
Dim dur As Bit
Dim ComingData As Byte
Dim B0 As Byte
Dim xpos As Byte
Dim ypos As Byte
Dim OKU As Byte
Dim ADRS As Word
Dim TEKRAR As Word
Dim ARRAY1[9] As Byte
Cls
BEGIN:
Dim i As Word
For i = 0 To 10 Step 1 '11 bitlik veri gelecek

While Clk =1 ' Ilk önce Clock=1 olmali
Wend

If i<9 & i>0 Then
ARRAY1[i]=ComingData
EndIf


While Clk = 0
Wend

While Clk = 0
Wend

Next

Cls
Print At 2,2, Str ARRAY1
DelayMS 500

GoTo BEGIN





End
Include "FONT.INC"

second part of the code for initalize GLCD ... There isn't any error..



' PROTON board for 16 series device
' Operating on 4MHz.
' Using a GRAPHIC LCD with an internal FONT

Device 16F877
XTAL 4
TRISB=%11010000
TRISA=%00000110
PORTB=0
LCD_DTPORT = PORTD
LCD_RSPIN = PORTC.1
LCD_ENPIN = PORTE.0
LCD_RWPIN = PORTC.0
LCD_CS1PIN = PORTE.1
LCD_CS2PIN = PORTE.2
LCD_TYPE = GRAPHIC
INTERNAL_FONT = On
FONT_ADDR = 0

SDA_PIN = PORTC.4
SCL_PIN = PORTC.3

SERIAL_BAUD = 2400
RSOUT_PIN = PORTC.6
RSOUT_MODE = TRUE
RSOUT_PACE = 1
RSIN_PIN = PORTC.7
RSIN_MODE = TRUE

HSERIAL_BAUD = 2400 ' Set baud rate to 2400
HSERIAL_RCSTA = %10010000 ' Enable serial port and continuous receive
HSERIAL_TXSTA = %00100100 ' Enable transmit and asynchronous mode
HSERIAL_CLEAR = On ' Enable Error clearing on received characters

'KEYPAD_PORT = PORTB
CCP1_PIN = PORTC.2
CCP2_PIN = PORTC.1

Symbol T300 = 3313 NO_LIST
Symbol N300 = 3313 + $4000 NO_LIST
Symbol T600 = 1646 NO_LIST
Symbol N600 = 1646 + $4000 NO_LIST
Symbol T1200 = 813 NO_LIST
Symbol N1200 = 813 + $4000 NO_LIST
Symbol T2400 = 396 NO_LIST
Symbol N2400 = 396 + $4000 NO_LIST
Symbol T4800 = 188 NO_LIST
Symbol N4800 = 188 + $4000 NO_LIST
Symbol T9600 = 84 NO_LIST
Symbol N9600 = 84 + $4000 NO_LIST

Symbol OT2400 = 396 + $8000 NO_LIST ' Open True
Symbol OT1200 = 813 + $8000 NO_LIST ' Open True
Symbol OT9600 = 84 + $8000 NO_LIST ' Open True
Symbol OT300 = 3313 + $8000 NO_LIST ' Open True

Symbol ON2400 = 396 + $4000 + $8000 NO_LIST ' Open Inverted
Symbol ON1200 = 813 + $4000 + $8000 NO_LIST ' Open Inverted
Symbol ON9600 = 84 + $4000 + $8000 NO_LIST ' Open Inverted
Symbol ON300 = 3313 + $4000 + $8000 NO_LIST ' Open Inverted

' Rsout / Serial Constants
Symbol HOME = 1 NO_LIST
Symbol BELL = 7 NO_LIST
Symbol BKSP = 8 NO_LIST
Symbol TAB = 9 NO_LIST
Symbol CR = 13 NO_LIST

ALL_DIGITAL = True ' Set PORTA and PORTE to all digital

Archangel
- 4th July 2009, 18:27
Hi boraciner, The project looks interesting, but this forum uses M E Labs PBasic not Proton, here is the link to the Proton Forum. I would be interested in following your project there, if you would do us the favor of posting a link in this thread to the new one you post there it would be appreciated. http://www.picbasic.org/forum/

boraciner
- 5th July 2009, 08:14
I have already opened a topic in that website, but no one answered..
If you're interested in, we can share our knowledge; I have a few robotics projects in my website : www.dreamrobotics.com
Secondly, My msn : [email protected] If you add me your contacts, we can communicate each other ...

Thanks a lot..