Yet another SERIN2 question


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default Yet another SERIN2 question

    Howdy

    I've fought this long enough - now am asking for help.

    What I have is a serial LCD backpack with a keypad interface as well. Using a PIC 16F870 . That all works fine.
    Sending serial characters, custom characters, etc to the LCD works fine.

    The problem I have is getting data back from the keypad.

    How it works is a request is sent to the keypad using a SEROUT2 command, ($FE,$1B,) an interrupt is returned, (active low), and after it goes high the key number is returned serially. This all works, I have attached a screen shot of the data transmissions from my logic analyzer.

    What I can't get to work is the SERIN2 to actually get the key value back in.
    As I said, the serial data (byte) is coming back, but the SERIN2 just "hangs", and never brings the data in.(must not see it) I tried using a timeout and label in the SERIN2 statement, but that was counter productive, 'cause the data was not being seen anyway.

    here is a short code segment

    serout2 Tx,84, [$FE,$1B] ' request for key data (code for this backpack)
    pauseus 500
    serin2 Rx,84,[key] ' get the key pressed from keypad buffer
    pauseus 500
    serout2 Tx, 84, [$FE,$0C,1,0,#key] 'display it on LCD line 2, position 1

    key jas been defined as a byte variable

    Tx is PORTC.7 and Rx is PORTC.6

    The interrupt is returned to PORTC.5

    4 Mhz oscillator is defined

    The attached screen shot from my logic analyzer shows the interrupt line, data request, and serial data returned. A decimal "9" is what is returned in this case.

    I've tried several variations of the SERIN2 command ( even tried SERIN with the "modedefs.bas" included )

    Should I be trying to receive the data in an interrupt routine? That does not seem necessary - - -

    Something simple, I'm sure - but I am stumped.

    Thanks

    Ken

  2. #2


    Did you find this post helpful? Yes | No

    Default Attachment for SERIN2

    can't seem to get this to work . .
    Attached Images Attached Images  

  3. #3


    Did you find this post helpful? Yes | No

    Default Attachment for SERIN2

    Sorry - I did not attach this correctly

    Ken
    Attached Images Attached Images  

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Ken,
    We just saw something like this a month or so ago, and what I learned from that thread is serin2 must have a non numeric character follow the numeric data in order to continue on it's way.<br>
    EDIT: AHAA I found it :http://www.picbasic.co.uk/forum/showthread.php?t=10786
    Last edited by Archangel; - 31st March 2009 at 17:30.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5


    Did you find this post helpful? Yes | No

    Default Serin2 problem - figured it out !

    Hi all

    It must have been timing related. I revised the code to :


    serout2 Tx,84, [$FE,$1B] 'Request data from Keypad

    pauseus 100 ' added a short delay

    serin2 Rx,84,10,cont,[key] ' put a Timeout & jump in so the SERIN2 will wait
    ' for a while for the data to come back

    cont: ' label to "jump to" if no data

    pause 50 'Not sure if this is needed, will play with it some

    serout2 Tx, 84, [$FE,$0C,1,0,#key] 'the decimal key value is now displayed
    ' The keypad defaults to 0 if a request
    'is made and no key pressed

    Anyway, now it works great. Learned something in the process too !

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    You have 4 open threads for the same problem ! WHY ? Please continue the saga within the original post, otherwise how do we know where to post our ideas as to how to help you.
    Last edited by Archangel; - 31st March 2009 at 18:06.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Dec 2006
    Location
    WADSWORTH OHIO USA
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Greetings
    How about some code...
    I'm use a system using 9 pics all using serin2/out2

    Note after initiating the read pause for 10ms for the write.
    This cured the universe for us.
    other option is to use a single clock source.
    Last edited by SOMRU; - 31st March 2009 at 20:14. Reason: more info
    Thanks !
    SOMRU
    TWE/TFP/EE

Similar Threads

  1. GPS $GPRMC to PIC16F684. Need help with SERIN2
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th November 2009, 09:47
  2. Getting SERIN2 to work?
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 22nd July 2009, 20:10
  3. SERIN2 digit parsing
    By skimask in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th January 2007, 23:15
  4. serin2 question
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd July 2006, 21:28
  5. SERIN2 Question
    By eoasap in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd January 2006, 15:43

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