Modem Auto Answer-Hanging for 1 min...


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Download this free terminal program and try the
    modem with the serial port of your PC.
    (Just 3 wires, RX,TX,GND)

    The program is only an EXE file, no setup.

    With this program you can create 12 macros.

    Example of macro:

    AT#013#010
    This will send AT and "CR" + "LF" (cariage return + line feed)

    Terminal program home page:
    http://bray.velenje.cx/avr/terminal/

    File download link:
    http://bray.velenje.cx/avr/terminal/dl.php

    Luciano

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Hi!

    The problem is not with the modem. It is with the PIC code executing up to a point then stops for a minute or so and then resumes.

    No interrupts or other source is envolved. The problem is on the 3 Hserout. If the 3 becomes 1 OR the LOCATION of the code changes, then it executes normally.

    This is the problem!

    I do not have to wait for the modem to respond. I just wait and give next command after a while.

    I believe it is a problem related with the "code crosses boundary @ ..." that shows up 3 times since the code is long enough.

    Ioannis

  3. #3
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I went quickly through your code.

    What you can read here is based on what I understand from
    the PicBasic Pro manual and the 16F877 datasheet.
    (Not tested with real hardware and software).

    ==================================

    DEFINE HSER_CLROERR 1

    If you use "DEFINE HSER_CLROERR 1", PicBasic Pro
    will generate the code that in background will take
    care of the FIFO RX buffer overrun error. When you
    send the AT commands with HSEROUT, the modem will
    respond after each single AT command with "OK".
    (In your case "0" + CR because of the use of "ATV0").
    So while you send the second or third AT command, the
    response of the modem to the first or second AT command
    will cause an overrun error and therefore the background
    code will be executed, which could be the cause of the problem.


    What happen with your code:
    (From the file you have previously attached).

    i=rcreg:i=rcreg

    Here you get (clear) the two bytes from the FIFO buffer.



    HSerout ["ATV0",13]'Set Numeric Response

    The modem sends back 2 bytes. (Ascii 48 and 13).



    HSerin 250,no_modem,[i] 'Wait for 0 "zero" (OK)

    You read the first byte (Ascii 48) of the two bytes
    waiting in the FIFO but one byte will remain in the FIFO.



    Hserout ["ats0=2",13,10]
    pause 500

    The modem sends back the 2 bytes response (Ascii 48 and 13)
    and while the UART receives the second byte the overrun error
    will occur. (One byte was already there before sending the AT
    command so 1+2=3 and with 3 you get the overrun error).
    The background code is executed to clear the error. At this
    point the FIFO is full.(Two bytes).


    hserout ["ATX3",13,10]
    pause 500

    The modem sends back the first byte of the two bytes response,
    (Ascii 48 and 13) and while the UART receives this first byte
    the overrun error will occur.
    (Two bytes were already there before sending the AT command so
    2+1=3 and with 3 you get the overrun error). The background
    code is executed to clear the error. After the overrun error
    is completed, the execution of your program will resume with the
    next statement which is Hserout ["AT&K0",13,10]. The execution
    will be interrupted by the overrun error caused by the second byte
    of the previous modem response.


    Solution 1:

    Keep "DEFINE HSER_CLROERR 1" but use a longer pause
    between the single AT commands and read the modem
    response from the double buffered register RCREG.
    This will ensure that the two bytes RX FIFO buffer is
    empty before you send the next AT command.


    Solution 2:

    Remove "DEFINE HSER_CLROERR 1".

    In order to be able to receive data in the UART you
    will have first to manually clear the overrun error with:

    RCSTA.4 = 0
    RCSTA.4 = 1

    ================================

    * * *

    ================================

    Also a possible improvement:

    Remove this line from your code.

    DEFINE HSER_BAUD 9600
    (Replaced by the 3 lines below).

    Make sure these 3 lines are in your code.

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 129 ' 9600 Bauds, error 0.16%

    ================================

    * * *

    ================================

    Small format errors:

    SUB "continue"
    pause 15000: (remove the colon : at the end of the line)

    SUB "com_device"
    i=rcreg:i=rcreg: (remove the last colon : at the end of the line)

    ================================

    * * *

    ================================

    Also a possible improvement:

    In your code I see that you use everywhere only CR
    after each AT command. Why do you use CR + LF now?

    Is ATZ the right AT command?

    ATZ means to reset the modem to the settings stored
    by the user. You usually have at least one set of
    registers for the user to customize their modem with.

    AT&F means to reset the modem to the factory default settings.

    A few modems take a moment to finish doing an AT&F and
    may ignore the next thing sent to them, though not many.
    Many will take quite a while to complete an ATZ, and will
    ignore the next things sent to them. You really have to
    wait for an OKAY response from the modem, before
    doing anything after an ATZ or AT&F.
    ================================

    * * *

    Best regards,

    Luciano

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Luciano, thank you for your extensive reply. The corrections were made, ok.

    As for the main problem, it has nothing to do with the external device. It's something related to the sub handling from PBP. Look at the following response taken from the Terminal program suggested earlier:

    ATE0
    ATV0 <-- at this point I am sending a 0 from the terminal
    ats0=2 <-- response is as expected from the program
    ATX3 <-- again as expected
    AT<00> <-- upto this point, were the command freezes!
    <-- then after a minute the <00> appears and execution
    continues normally!

    AT+CMGF=1
    ATS37=9
    ATS40=2

    So the problem is inside the UART of the PIC as it may look...

    Ioannis

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you disconnect the modem, and just monitor serial data the PIC is sending, what results do you get?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hello,

    My theory was wrong.

    Bruce in the post #13 there is no modem connected.

    The post #13 as I understand it:

    The PIC sends "ATE0" to the RX pin of the PC. (The terminal program of the PC shows ATE0).

    The PIC sends "ATV0" to the RX pin of the PC. (The terminal program of the PC shows ATV0).
    Ioannis types "0" in the terminal program of the PC and the PIC gets this byte
    otherwise no further AT commands are sent by the PIC.

    The PIC sends "ats0=2" to the RX pin of the PC. (The terminal program of the PC shows ats0=2).

    The PIC sends "ATX3" to the RX pin of the PC. (The terminal program of the PC shows ATX3).

    The PIC sends "AT&K0" to the RX pin of the PC, but the PC terminal program shows only
    AT and after a minute in addition to AT the PC receives also <00>. So after a minute
    on the PC screen you will see AT<00> and the execution of the program continues normally
    in the PIC. (So the PIC does not successfully send AT&K0 to the PC).

    Ioannis please confirm that.

    Luciano
    Last edited by Luciano; - 17th August 2005 at 23:15.

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Luciano yes. You are right. This is exactly the case. Bruce, sorry, in #13 I did not clearly stated that the device was disconnected.

    Please also note that, if all the 3 Hserin commands are joined as one then there is NO problem in the transmitted string! (I do not know if there is other problem in some other subroutine though...)

    So, as I can conclude up to this moment, there must be some difficulty from PBP to work with many and some long sub routines.

    Also, if the subrounines are transfered from the top to the bottom then this problem disappears! (Others from other sub's are appearing then...)

    Black Magic or what?

    Ioannis

Similar Threads

  1. No Modem response
    By jimboho in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 11th November 2004, 05:58

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