#PICAXE 14M2
#Terminal 19200
Symbol TlfSet = B.4 '"SET" pin, when low, places module into command mode
Symbol TXpin = B.3 'output to HC-12
Symbol RXpin = B.2 'input from HC-12
Symbol TlfBaudRate = T9600_16 'HC-12 Baud rate
PowerOnReset:
High TXpin '??????????
' Low TlfSET
SetFreq M16
SerTxd( Cr, LF, "Started PowerOnReset", CR, LF )
pause 4000
MAIN:
b1 ="?" : b2 = "?" : b3 = "?" : b4 = "?"
b5 ="?" : b6 = "?" : b7 = "?" : b8 = "?"
SerOut TXpin, TlfBaudRate, ( "AT+CMGF=1 )
Serin [8000], RXpin, TlfBaudrate, b1,b2,b3,b4,b5,b6,b7,b8
if b1 = "?" OR b1 = "E" Then
SerTxd( "No response", CR, LF )
Else
SerTxd( "R:", b1,b2,b3,b4,b5,b6,b7,b8, CR, LF )
End if
pause 4000
goto MAIN
and get:
Started PowerOnReset
No response
No response
No response
No response
No response
R:[FF]???????
R:[00][FF][00][F0][FF][00][FF][1F]
R:[FF]???????
R:[03][FE][00][FF][FF][00][FF][FF]
R:[00][FE][00][FE][EF][00][FF][01]
R:[FF][01][FF][FF][00][00][FF][00]
Some thing wrong with Baud Rate and " High TXpin '???????????"?
torben
Possibly. Posting a link to the exact module you have and its datasheet will help members answer whether you should and whether doing so will be useful.Can I connect a usb -> mini usb cable between thr PC and the gsm?
#Picaxe 14m2
HSerSetup B115200_4,%000
SerTxd( #B115200_4, CR, LF )
#Picaxe 28X2
HSerSetup B115200_8, %000
Do
HserOut 0, ( "U" )
Pause 100
Loop
|<----- 78us ---->|
_____ _ _ _ _ _____
|_| |_| |_| |_| |_|
S 0 1 2 3 4 5 6 7 P
You should be able to do what you want without a scope. A scope is only really useful for checking that something is going to the module or coming back. If data is passing then it should be possible to figure any other problems out without the scope.I have to get a better scope.
___ _ _ _ _ ___
Idle High U = $55 |_| |_| |_| |_| |_|
S 0 1 2 3 4 5 6 7 P
___ _ _ ___
Idle High A = $41 |_| |_________| |_|
S 0 1 2 3 4 5 6 7 P
_ _ _ _ _
Idle Low U = $55 ___| |_| |_| |_| |_| |___
S 0 1 2 3 4 5 6 7 P
_ _________ _
Idle Low A = $41 ___| |_| |_| |___
S 0 1 2 3 4 5 6 7 P
That is correct.As I understand your last message idling high means that the start bit is a 0. And the data are transmitted least significant bit first
It is more data rate than baud rate which is most important; how quickly characters/bytes are being sent in a stream. If bytes are sent too quickly after each other the PICAXE may not have processed the first before receiving the next and may miss or corrupt that. Using a slower baud rate gives the PICAXE more time to deal with the first before it has to deal with the second. Running at a higher operating speed can also help.I also understand that the transmission speed of the UART is independent of the clock frequency. I assume that the transmission speed must be high enough so that bytes coming in do not overtake the transmission.
Both hSerPtr and hSerFlag can be ignored when using HSERIN to read direct to Scratchpad. They really only apply to using Background receive..In the example given for hSerIn by Picaxe there is no mention of hSerPtr or hSerFlag. Do I have to deal withn that?
Or can I just retrieve get 0,b0, get 1,b1, ..... (I am using 28X2)
There are some posts on the forum regarding GSM modules including -Is there anywhere a basic example of the communication hSerOut/hSerIn (fx. with a mobile phone)?
Post the full code you are using and we can check if it looks like it should work, and what you should be seeing.The scope shows that something is sent, but I dont think it is what I input.
#PICAXE 28X2
#Terminal 9600
hSerSetup B2400_8,%001
pause 2000
SerTxd ("Started.....",cr,lf)
MAIN:
do
hSerOut 0, ( "AT+CMGL=",$22,"ALL",$22,CR )
'hSerOut 0, ( "AT&F",CR )
pause 2000
SerTxd ("hSerPtr: ", @Ptr," ",hSerPtr, cr,lf)
do while ptr <> hSerPtr
SerTxd (@PtrInc)
loop
SerTxd (cr,lf,"----",cr,lf)
loop
#PICAXE 28X2
#Terminal 9600
hSerSetup B2400_8,%001
pause 2000
SerTxd ("Started.....",cr,lf)
MAIN:
do
hSerOut 0, ( "AT",cr )
pause 2000
do while ptr <> hSerPtr
b0 = @ptrInc
SerTxd ( "Rx", tab, #b0, tab, $22, b0, $22, cr,lf )
loop
SerTxd ("----",cr,lf)
loop
HSerSetup Bxxxx_8, %001
Pause 2000
HserOut 0, ( "+++" )
Pause 2000
That would seem to be correct.I have tried 2400, 4800, 9600,19200, 38400, 76800, 115200 together with _4, _8, _16 and all I get back is "----". Which means "no answer" I suppose.
I would double check the wiring. Especially that the wires are not crossed over.Since I at one time did get "OK" as the answer to "AT"cr it appears that something has gone wrong with the phone. I have tried "AT&F" (reset).
You shouldn't receive anything if the phone is not connected though electrical interference and pick-up might generate some meaningless data.The thing that disturbs me though is that I get rubish if the phone is not connected - I should get "AT". Right?
I other words, the hSerOut should first fill up the scratch pad area with "AT" and next fill it up with the return (OK) from the phone.
It sets the baud rate. The frequency is 8MHz by default. You need to adjust that to match the frequency used if there is any SETFREQ command.I assume that 2400_8 both sets the transmission speed and the clock rate?
Yes; I was expecting you to change the 'xxxx' to the baud rate value, eg '4800' etc.The compiler rejects hSerSetup Bxxxx_8, %001
HSEROUT sends the "AT", everything received is automatically handled by the background receive code by the PICAXE firmware, specified by the %001 in the HSERSETUP command.Maybe I should rather ask what fills in the AT I should see on the screen and what fills in the OK reply, since there is no hSerIn.
It is more common to connect hSerOut to an RXD pin, because that's how it is from the device's perspective, but sometimes a pin can be labelled TXD to indicate what it connects from. And, yes, it can be confusing!What a relief! But is that not unusual to connect hSerOut to U_TXD and hSerIn to U_RXD? It did not occur to me
Almost. Normally "AT<CR>" is send out, "OK<CR><LF>" is echoed back.And I understand that "AT" is echoed back and "OK" is transmitted to the pgm. - no hSerIn needed. I understand things now.
#Picaxe 28X2
#Terminal 9600
#No_Data
#No_Table
#Macro Send(text)
SerTxd( "Send : ", text, CR, LF )
HSerOut 0, ( text, CR )
Gosub GetReply
#EndMacro
Init:
HSerSetup B115200_8, %001
Main:
Pause 2000
SerTxd( "Started", CR, LF )
Send( "AT")
Send( "AT+GMI" )
Send( "AT+GMM" )
End
GetReply:
Pause 2000
Do While ptr <> hSerPtr
b0 = @ptrInc
If b1 = CR And b0 <> LF Then
SerTxd( CR, LF )
End If
Select Case b0
Case CR : SertXd( "<CR>" )
Case LF : SertXd( "<LF>", CR, LF )
Else : SerTxd( b0 )
End Select
b1 = b0
Loop