How to use RSIN


Closed Thread
Results 1 to 6 of 6

Thread: How to use RSIN

  1. #1
    Join Date
    Mar 2007
    Location
    Brisbane
    Posts
    3

    Question How to use RSIN

    I'm having a lot of trouble reading serial input! Can anyone help?
    The circuit is receiving input from a computer running Hyperterminal set at 9600,N,8,1. (There's no MAX232 driver chip.) Here's the code -

    Device=16F877
    XTAL=20

    Declare SERIAL_BAUD = 9600
    Declare RSIN_PIN = PORTA.0
    Declare RSIN_MODE = 0
    Declare RSIN_TIMEOUT = 10000

    Dim Serdata As Byte
    TRISD=%00000000 'Just to prove the computer has started
    PORTD=%00000100 'turn on an LED
    Print "Waiting..."
    DelayMS 1000
    Start:
    Serdata=RSIn,{TO_ERROR}
    Print HEX Serdata, "*"
    GoTo Start
    TO_ERROR:
    Print Cls, "Timed Out"
    Stop

    The program produces the following result on power-up:
    With RSIN MODE set to 1, (which I think is right) I get "Waiting", 1 second delay, 0*0*0*0*0*.......... but never any input characters.
    With RSIN MODE set to 0, I get "Waiting", 11 second delay, "Timed Out"

    The signal on pin 2 of the 16F877 is roughly -
    +5v __ __ __

    -0.5v _______ __ __ ___________

    I have tried an 18F4550 with same result. I must be missing something important here!

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612

    Default

    Hi Tim,
    I'd love to be able to help you but I think you are in the wrong forum. I don't know which compiler you're using but this forum is for the Micro Engineering Labs PIC Basic Compilers (Standard and PRO).

    Sorry....
    /Henrik Olsson.

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

    Default

    This is PROTON PDS. As usual, the PORTA have some multiplexed analog stuff on PORTA that MUST be disable first.

    ADCON1=7
    or
    ALL_DIGITAL = TRUE

    should do the trick. Also, you should set your config fuses. something like
    Code:
    REMINDERS=FALSE
    Config LVP_OFF, HS_OSC, WDT_OFF
    The right forum for you will be www.picbasic.org/forum
    Last edited by mister_e; - 6th March 2007 at 15:39.
    Steve

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

  4. #4
    Join Date
    Mar 2007
    Location
    Brisbane
    Posts
    3

    Smile

    Thanks for your feedback. I'll try the Proton PIC Basic Development Forum.
    But I'll also take on board your advice, thanks Steve.

  5. #5
    Join Date
    Mar 2007
    Location
    Brisbane
    Posts
    3

    Smile Problem solved

    Many thanks, Steve. ADCON1=7 did the trick!

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

    Default

    Good! it's just weird that it's worked even without MAX232 and in TRUE mode.. but anyways.

    enjoy!
    Steve

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

Members who have read this thread : 0

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