Small great problem


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Location
    Ferrara - Italy
    Posts
    13

    Unhappy Small great problem

    Hi to everybody!
    I would like to realize a device that converses with a PC through the door PS2, using a PIC 16F877A.

    The device should send to the PC, the letter "r" if the key P1 is pressed on RD0, the letter "c" if the key P2 is pressed on RD1 and the letter "s" if the key P3 is pressed on RD2.

    I have realized the following code, but it doesn't work... where is the error?

    Thanks everybody!
    Best regards!

    @ DEVICE HS_OSC
    @ DEVICE pic16F877A
    DEFINE OSC 20
    DEFINE SHIFT_PAUSEUS 15

    INCLUDE "modedefs.bas"

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCD_LINES 2

    symbol P1 = PORTD.2
    SYMBOL P2 = PORTD.1
    SYMBOL P3 = PORTD.0
    symbol LED = PORTA.0
    Symbol dat = PORTC.0
    symbol clk = PORTC.1

    i var byte
    Value Var word
    clear

    ADCON1 = 7
    dat = 1
    clk = 1

    lcdout $fe,1,"** Test PS2 **"
    LCDOUT $fe,$c0,"Value: ",Value," "

    FOR i = 0 TO 5
    TOGGLE LED
    PAUSE 200
    NEXT i
    GOTO Main

    Main:
    if P1 = 0 THEN
    Dato = $73
    lcdout $fe,$c0,"Key: ",Value," "
    Pause 50
    GOSUB TX
    endif

    if P2 = 0 then
    Dato = $63
    lcdout $fe,$c0,"Key: ",Value," "
    Pause 50
    GOSUB TX
    endif

    if P3 = 0 then
    Dato = $72
    lcdout $fe,$c0,"Key: ",Value," "
    Pause 50
    GOSUB TX
    endif

    goto Main

    TX:
    shiftout dat,clk,0,[Value\11]
    pause 50
    return

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Variable Value is not loaded with the character that you load into byte Dato, if you want it to be displayed than either you print also variable Dato or as in the example below you transfer Dato into Value.

    correct your ascii code for the letters c;r and s


    Code:
    '$63 = c
    '$72 = r
    '$73 = s
    
    if P1 = 0 THEN
    'Dato = $73 ' 
    Dato = $72
    Value=Dato
    lcdout $fe,$c0,"Key: ",Value," "
    Pause 50
    GOSUB TX
    endif
    Al.
    All progress began with an idea

  3. #3
    Join Date
    Jul 2005
    Location
    Ferrara - Italy
    Posts
    13


    Did you find this post helpful? Yes | No

    Red face

    Quote Originally Posted by aratti View Post
    Variable Value is not loaded with the character that you load into byte Dato, if you want it to be displayed than either you print also variable Dato or as in the example below you transfer Dato into Value.

    correct your ascii code for the letters c;r and s


    Code:
    '$63 = c
    '$72 = r
    '$73 = s
    
    if P1 = 0 THEN
    'Dato = $73 ' 
    Dato = $72
    Value=Dato
    lcdout $fe,$c0,"Key: ",Value," "
    Pause 50
    GOSUB TX
    endif
    Al.
    Thanks Aratti! Thanks very much!
    I have effected the changes from you signalled and in effects we are now all some right ... It's still me impossible to send the data on the PS/2. Is it possible that the error is in the command SHIFTOUT?

    Thanks very very muche for your irreplaceable help!

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    .... Is it possible that the error is in the command SHIFTOUT?
    I think you have spotted the problem. Read the thread @ the given link, it will help you in understanding the ps2 protocol.

    http://www.picbasic.co.uk/forum/show...=communication

    Al.
    All progress began with an idea

  5. #5
    Join Date
    Jul 2005
    Location
    Ferrara - Italy
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    I think you have spotted the problem. Read the thread @ the given link, it will help you in understanding the ps2 protocol.

    http://www.picbasic.co.uk/forum/show...=communication

    Al.
    Thank you very much!

Similar Threads

  1. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  2. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  3. Hardware problem or what ?
    By Steve S. in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 4th March 2007, 21:39
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. HSEROUT Problem
    By Keith in forum General
    Replies: 2
    Last Post: - 25th June 2005, 15:09

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