To Melanie, Dave and Ingvar!!How to reset USART module in PicBasic?


Closed Thread
Results 1 to 6 of 6
  1. #1
    fbestepe's Avatar
    fbestepe Guest

    Default To Melanie, Dave and Ingvar!!How to reset USART module in PicBasic?

    Hi Everyone,

    I asked a question about MCLR reset before, now I would like to ask how to reset USART module? The problem is not changed, it is the same before, but I understood that my problem is related with USART module. The infrastructure is like that, I am connecting to 16F877 using hyper terminal with dial up connection over 2 external modems. The connection between remote modem and 16F877 is fullfiled via USART. The problem is that, after the dial up connection is established, the device (16F877) is needed to be MCLR reset in order to receive and/or transmit characters properly. (That is, Hserout/Hserin does not work until MCLR)
    Interestingly, if the connection between remote modem and 16F877 is fullfiled over PortB.0, PortB.1 with inverted logic, everything is OK, there is no need any reset. (Serin2/Serout2 works perfect.)
    I have to use USART module for this connection and I need your help very much. In my opinion, if I can only reset USART module, I will be able to solve this problem.
    I am waiting for your recommendations.
    Thanks and Regards,
    Firat

  2. #2
    electronicsuk's Avatar
    electronicsuk Guest


    Did you find this post helpful? Yes | No

    Default

    Perhaps you just need to clear the serial port enable bit SPEN, can't remember the exact register it is located on but it should say so in the datasheet. The problem could be because you are receiving invalid data and causing a framing error or overrun when connecting up, so you just need to clear it by disabling and then re-enabling the UART.

    Matthew

  3. #3
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Hi Firat,

    The more recent versions of PBP has the ability to automatically clear an overrun error. Just add "DEFINE HSER_CLROERR 1" in your program. If this doesn't help you'll need to post your code, details about your hardware(serial), PBP version , etc. Too little information makes it impossible to help.

    /Ingvar

  4. #4
    fbestepe's Avatar
    fbestepe Guest


    Did you find this post helpful? Yes | No

    Default Thanks Ingvar!!! U are a real problem punisher

    Thanks Ingvar (good Swedish guy),

    "DEFINE HSER_CLROERR 1" statement solved the problem, as you said. That is very fine. Thanks .

    Note: I was in Visby in September, I liked very much Swedish people.

    Firat.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Firat, In the past I have had problems with the usart in an 16F628 and found that before using the internal usart if I sent the commands:
    IF RCSTA.1 = 1 THEN 'if overrun error bit is set
    RCSTA.4 = 0 'clear CREN continous receive enable bit
    RCSTA.4 = 1 'set CREN continous enable receive bit
    ENDIF
    What this does is to reset the internal overrun error latch that when set inhibits any received data bytes, effectively disabling the usart. Adding these lines of code just before the usart use will make sure the usart will receive the data. This had to be used before the PBP compiler was updated with the added command of: DEFINE HSER_CLROERR 1 which does this function in the background.

    Dave Purola,

  6. #6
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Talking

    A good friend of mine used to say "Flattering will get you everywhere"(or was it anything), it works :-)

    Never been to Visby myself, yet. I hear that it's really nice in the summer, but that's true for most parts of Sweden.

    Cheers
    /Ingvar

Members who have read this thread : 2

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