explanation about HSERIN command!


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Maybe this will help?
    From the manual
    Quote:
    As the hardware serial port only has a 2 byte input buffer, it can easily overflow if characters are not read from it often enough. When this happens, the USART stops accepting new characters and needs to be reset. This overflow error can be reset by toggling the CREN bit in the RCSTA register. A DEFINE can be used to automatically clear this error. However, you will not know that an error has occurred and characters may have been lost.

    *** DEFINE HSER_ CLROERR*** 1

    To manually clear an overrun error:

    *** RCSTA. 4 = 0*
    *** RCSTA. 4 = 1

    dear mackrackit,

    I changed the code to manually clear the buffer,but unfortunately it gives the same incorrect result as before .

    thank you for yr help,



    dear

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Can you tell us what you are sending and the result?
    Also, how is your hardware set up?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    hi mackrackit,

    Also, how is your hardware set up?
    three PICs are attached to a master PIC all of type 16F877A using RS-485.

    configuration without leds lcd definitions :

    * MASTER PIC:



    Include "Modedefs.bas"
    DEFINE OSC 4
    DE_OR_RE VAR PORTC.5
    RS232_DEBUG_PIN VAR PORTB.5
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_SPBRG 25
    DEFINE HSER_BAUD 2400
    DEFINE HSER_CLROERR 1
    OPTION_REG.7 = 0
    CMCON = 7
    ADCON1 = 7
    B0 = 0

    SLave PIC:

    Include "Modedefs.bas"
    DE_OR_RE VAR PORTC.5
    DEFINE HSER_RCSTA 90h
    define HSER_TXSTA 20h
    define HSER_SPBRG 25 'SPBRG 2400
    DEFINE HSER_BAUD 2400
    DEFINE HSER_CLROERR 1
    DEFINE OSC 4 ' We're using a 4 MHz oscillator
    DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
    DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
    DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
    TRISA = %11111111
    PORTA = %00000000
    OPTION_REG.7 = 0
    CMCON = 7
    ADCON1 = 0


    Can you tell us what you are sending and the result?
    i'm sending from another PIC 1's and 0's which represent the status of my sensors it's attached on analog pins(four sensors for each slave PIC).
    The result should be also received as 1's and 0's as sent in sequence.

    thanks for help...

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    485 ....
    Have you enabled/disabled the TX pin?
    If you are not familiar with 485 this is a good read
    http://www.bb-elec.com/tech_articles...f_contents.asp

    And buried in this thread is some code.
    http://list.picbasic.com/forum/messa...html?996705165

    Post your whole code so we can take a look.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    hi mackrackit,
    sorry for being late but i had some wrok to do the previous days..
    here're the full code attached down, so it'll be easier to detect the errors.

    Have you enabled/disabled the TX pin?
    yea, i'm already receiving and sending but my problem is the incorrect received values.

    thanks alot...
    Attached Files Attached Files

Similar Threads

  1. explanation on I2C command (PBP)
    By F1CHF in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th May 2014, 05:30
  2. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  3. HSERIN and XOUT command
    By aratti in forum General
    Replies: 20
    Last Post: - 12th May 2009, 11:58
  4. Can I do this???
    By noobie in forum mel PIC BASIC
    Replies: 2
    Last Post: - 10th June 2006, 18:57
  5. HSERIN command - Still searching for answers
    By electronicsuk in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 26th December 2003, 09:28

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