Modem Auto Answer-Hanging for 1 min...


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default

    Hmm, how much would you bed on it?? **smiles**!

    The problem is still there. I just moved the sub's from top of program to the bottom of it and this part works OK now! Any explains? I usually put all sub's on top.

    It is weird...

    Ioannis

    P.S. Of course half of the sub's do not work!!!
    Attached Files Attached Files
    Last edited by Ioannis; - 16th August 2005 at 12:52.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Is that an invitation?

    Short of going through your program line by line I can't comment, but what version of PBP are you using? I do recall early versions of PBP did have some issues, and I do recall some strange things in 2.42... but ceratinly not now.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Just curious if when you send all commands at once are you certain that all commands are received and processed? The PIC might sending the info too fast and the modem is only responding to one of the commands when it replies "OK". This I think would be along the same lines as Melanie thoughts.

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


    Did you find this post helpful? Yes | No

    Default

    Thanks all. Well, Melanie of course it is! I do challenge you!

    By no means I asked to go through line by line. Just for reference the code was included.

    The version is latest. I had from time to time problems with subroutines and the way was to shorten the length of each one. Now, the symptom is quite strange and the program execution even more. As stated earlier the third Hserout executes to the point ats0= and then it stops for about a minute! This I saw with my eyes on a terminal program. By now there is no explanation as to what might happening.

    If the three commands are joined then the execution flows like calm water.

    About the modem, cocacolakid, the modem has no problem to process the commands, since the CR/LF has not arrived yet.

    Ioannis

  5. #5
    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

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    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

  7. #7
    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

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