SERIN AND SEROUT PROBELM USING 16f690 PIC


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2007
    Posts
    5

    Default SERIN AND SEROUT PROBELM USING 16f690 PIC

    HI , i have a little project...i have problem in sending data from one pic to another PIC using serin and serout...i'm using keypad to get the input(therefore the input will be a number) and i want to send it to the second pIC and display it on the LCD.

    The problem is when i press the keypad, when i display it on the LCD it always give 0..i'm sure myway accessing the keypad is correct but the way to sending the data to the another pic maybe isn't correct..

    CAN ANY ONE HELP ME PLEASE WITH THIS PROBLEM BECAUSE I ONLY HAVE 2WEEKS LEFT BEFORE MY PROJECT due date time..

    HERE IS MY CODE

    ---------KEYPAD(TRANSMITTER)---------

    INCLUDE "bs2defs.bas"
    DEFINE CHAR_PACING 500
    ANSEL=0
    TRISC = %10000111 ; port for keypad
    TRISB = %00000000
    dgood var portB.4 ;indicate that anykey has been pressed or not
    outpin var portB.7 ; output to another PIC

    col1 var portC.0
    col2 var portC.1
    col3 var portC.2
    row1 var portC.3
    row2 var portC.4
    row3 var portC.5
    row4 var portC.6
    val var byte

    define OSC 8

    getkey:
    pause 50
    high dgood ; if high no key is pressed

    ;check which number has been pressed
    row1=0
    if col1 = 0 then one
    if col2 = 0 then two
    if col3=0 then three
    row1 =1

    row2=0
    if col1 = 0 then four
    if col2 = 0 then five
    if col3=0 then six
    row2 =1

    row3=0
    if col1 = 0 then seven
    if col2 = 0 then eight
    if col3=0 then nine
    row3 =1
    row4=0
    if col1 = 0 then star
    if col2 = 0 then zero
    if col3=0 then hash
    row4 =1
    goto getkey

    one:
    val =1
    goto valid
    two:
    val =2
    goto valid
    three:
    val =3
    goto valid
    four:
    val =4
    goto valid
    five:
    val =5
    goto valid
    six:
    val=6
    goto valid
    seven:
    val =7
    goto valid
    eight:
    val =8
    goto valid
    nine:
    val =9
    goto valid
    star:
    val =%00101010
    goto valid
    hash:
    val =%00100011
    goto valid
    valid:
    low dgood ; if any key pressed make it low and star send data
    serout outpin,t2400,[val]
    keypress:
    if (col1&col2&col3)<>1 then keypress;check if key has been released or not
    goto getkey


    ------------------receiver---------------
    INCLUDE "bs2defs.bas"
    DEFINE LCD_DREG portC
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG portA
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG portA
    DEFINE LCD_EBIT 1
    DEFINE LCD_LINES 2
    DEFINE LCD_BITS 8
    DEFINE LOADER_USED 1
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAAUS 250
    DEFINE OSC 8

    ABSEL =0
    trisB=%11111111
    keyinput var portB.5 ;port that received data from the transmitter
    num var byte ; containing the numbers that will be display
    valid var byte;indicator that key has been pressed and start receive data

    pause 50
    loop:
    lcdout $FE,1
    LCDOUT $FE,$80
    lcdout "ENTER polarity"
    LCDOUT $C0
    LCDOUT "1)+ 2)-"
    gosub wait1
    LCDOUT $FE,$C0+11,#num
    pause 500
    goto loop

    wait1: ;wait until key has been pressed
    if valid =1 then wait1
    serin keyinput,t2400,num

    wait2:;wait until key has been released
    if valid = 0 then wait2
    return
    end

    HOPE U GUYS CAN HELP ME>..THANX VERY MUCH

    end
    thanx

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles View Post
    CAN ANY ONE HELP ME PLEASE WITH THIS PROBLEM BECAUSE I ONLY HAVE 2WEEKS LEFT BEFORE MY PROJECT due date time..

    HOPE U GUYS CAN HELP ME>..THANX VERY MUCH

    end
    thanx


    Somebody stop me before I get started!!!

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Q: What sets the valid in the RX code?
    A: Nothing.

    So the program is doing exactly what you set it up to do...nothing but sit in a stuck loop. Which loop? Your turn to figure that one out. Hopefully it doesn't take you 2 weeks to do that. Maybe ask your instructor for some instruction on how to follow basic logic from start to finish...or in this case, from start to stuck...

  4. #4
    Join Date
    Jan 2007
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    what sets the valid in Rx is the dgood(pin) from transmitter so whenever the key pressed, the dgood become low and it is connected through wire to the valid pin in receiver so it will go out from the wait loop and display...
    the thing is all goes well accept the value inside the num(register) is 0 when i display..is the way i use the serin and serout is correct?...do u have any suggestion..thanx very much

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles View Post
    what sets the valid in Rx is the dgood(pin) from transmitter so whenever the key pressed, the dgood become low and it is connected through wire to the valid pin in receiver so it will go out from the wait loop and display...
    the thing is all goes well accept the value inside the num(register) is 0 when i display..is the way i use the serin and serout is correct?...do u have any suggestion..thanx very much

    Ok, back to you again, what sets valid = 1 or valid = 0?

  6. #6
    Join Date
    Jan 2007
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    in the transmitter part
    u see the dgood pin..it is connected to valid pin in receiver...
    therefore whenever i press the keypad, dgood become low which indicate valid =0...therefore it will goes out from the wait loop (in the receiver part) and display the number inside

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


    Did you find this post helpful? Yes | No

    Default Schematic anyone?

    Hey Charles, you suppose we could see a schematic? It sort of looks as if you want to send serial data from one pic to the other, hence skimasks question, but if you have everything all hardwired together, then we need to see how.
    JS

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles View Post
    in the transmitter part
    u see the dgood pin..it is connected to valid pin in receiver...
    Yes, but on the receiver side, valid is a BYTE, not a Pin.

    So back to skimask's question,
    "What sets the valid in the RX code?"
    <br>
    DT

  9. #9
    Join Date
    Jan 2007
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    dgood (portB.4) from PIC1 i connect it to valid(portB.6) from PIC2...sorry there is a mistype in the code it should be valid var portB.6 not valid var byte...then otupin(portB.7) from PIC1 is connected to keyinput(portB.5) from PIC2)/....yup i'm trying to send data serially from pic1 to pic2...any suggestion?thanx very much...

    best regards
    Charles

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Yes, but on the receiver side, valid is a BYTE, not a Pin.

    So back to skimask's question,
    "What sets the valid in the RX code?"
    <br>
    But he's only got TWO WEEKS!!!! AAAaaaaaaaaaaaaa.............

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Easy skimask, Down boy, Down!

    Let me take this one ...

    I'm always skeptical when someone Cut&Pastes their entire program into a Post.
    And, the one thing that points out a definate cause of the described problem suddenly turns into a "typo".

    In the middle of a Cut&Paste? Come on!

    See, I can do it too.

    Ok well, my advice is to dump the keypad routine, and use this...

    Matrix Keypad routine (mister_e)
    http://www.picbasic.co.uk/forum/showthread.php?t=3250

    Then take a look here...

    How to make your own PIC network (mister_e)
    http://www.picbasic.co.uk/forum/showthread.php?p=5708
    Not exactly what you are doing, but the concepts are the same. Just 2 PIC's instead of many.
    <br>
    DT

  12. #12
    Join Date
    Jan 2007
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    The output my program right now when i display on the lcd is

    ENTER POLARITY
    1)+ 2)- 0(this zero should be number that is pressed on the keypad)

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OK skimask,

    You have my permission.

    Pfft!
    <br>
    DT

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    OK skimask,

    You have my permission.

    Pfft!
    <br>
    Well, I'm guessing that he's using one of them thar 17C756, or maybe not. I can't tell.

    And I'm also guessing that he's using a bunch of switches, maybe even, dare I say, a telephone keypad, probably without any pullup or pulldown resistors (although there are ways around that). Again, I can't tell.

    And I'm betting that the search function hasn't been used much, 'cause there's a lot of info out there on connecting 2 PICs together and using a matrix style keypad. I'm at a loss...

    Oh, and I've got this car, it's making this noise. Can you help?

    Back at ya...

Similar Threads

  1. SERIN and SEROUT
    By CumQuaT in forum mel PIC BASIC
    Replies: 10
    Last Post: - 3rd September 2009, 00:17
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. 16f690 crashes
    By Lincoln S. in forum Serial
    Replies: 8
    Last Post: - 26th November 2008, 08:32
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

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