View previous topic :: View next topic |
Author |
Message |
antonio1964
Joined: 14 Oct 2006 Posts: 2
|
Posted: Sun Oct 15, 2006 12:12 pm Post subject: Problem receiving data from serial port with modem TC35i |
|
|
Hello, i am new to this field. I have started to program AT89C51 microcontrollers.
I had done transmitting data via serial port successfully and received data
on hyper terminal on pc, but when i'm going to receive it from modem tc35i, only receive one character. (response "OK" but only receive "O").
Sure my program is bad. Please help me . Thank you. This is my code:
' Send & Receive to MODEM
' Equipos:
' Modem GSM Siemens TC35i
'
' Antonio
' 10-Oct-2006
Declare Sub Sacadatos(s As String * 20)
Dim T As Integer
Dim S As String * 20 ,
Dim A As Byte
Enable Interrupts
$baud = 4800
Config Lcd = 20 * 2
Enable Serial
'p3.7 is a switch
P3.7 = 0
'Init
Cls : Locate 1 , 1 : Lcd "Init................"
Print "ATZ" : Wait 2
Cls
Do
'Send AT Command
Print "AT" 'AT
'Receive data and prompt
Sacadatos S : Locate 2 , 1 : Lcd S : Wait 1
'Send ATI Command
Print "ATI" 'ATI
'Receive data and prompt
Sacadatos S : Locate 2 , 1 : Lcd S : Wait 1
Loop Until P3.7 = 1
'END
CLS: Locate 1 , 1 : Lcd "END PROGRAM "
Disable Serial
End
'=============================================
'Read Data from MODEM
Sub Sacadatos(s As String * 20)
S = "" : T = 0
Do
T = Inkey
If T > 0 And T <> 10 And T <> 13 Then
S = S + Chr(t)
End If
Loop Until T = 10
End Sub
'============================================= |
|
Back to top |
|
|
Funci
Joined: 03 Aug 2005 Posts: 58 Location: CRO
|
Posted: Tue Oct 17, 2006 12:34 pm Post subject: |
|
|
Are you sure that you have correct baud rate? |
|
Back to top |
|
|
antonio1964
Joined: 14 Oct 2006 Posts: 2
|
Posted: Tue Oct 17, 2006 3:26 pm Post subject: |
|
|
Hi,
The modem is set as autobaudrate. I can send without problems.
How does the "SCON" register work? Can you explain it to me?
Thank you. |
|
Back to top |
|
|
Funci
Joined: 03 Aug 2005 Posts: 58 Location: CRO
|
Posted: Wed Oct 18, 2006 2:33 pm Post subject: |
|
|
I don't know how to explain Scon, because I don't using it. But my advice about your problem is to change conception of your program!
Try to make program without calling subrutines, I am thinking that you spend to much time on that jumps, or try the same program but with very slow baud! |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Mon Nov 20, 2006 12:06 am Post subject: |
|
|
hi antonio1964,
dont know the right commands for 80xx avr
but can you make a buffer for input like a ringbuffer size(max uotput len from modem)
then
send command
wait some time (150 -250 ms)
read from modem (stored in buffer) _________________ / Kim |
|
Back to top |
|
|
|