5

The GSM modem I have is set to 115200 baud-rate by default. I have PIC18 Microcontroller connected to it with 19200 baud-rate. I changed the modem baud-rate to 19200 then saved the settings but every time I reset the modem, the baud-rate changes back to 115200.

These are the following commands I used.

Change baudrate

AT+IPR=19200

Then I reopened the hyper-terminal (Putty) with 19200 baud-rate to save the current settings.

Save settings

AT&W

But upon reset of the modem, the baud-rate changes back to 115200. I am using M6000 GSM/GPS Module(Tk115 Gps Tracker) but there isn't a lot of support for it, here is the datasheet for reference.

Am I saving the settings correctly?

I was thinking about changing the baud-rate to 115200 on my PIC18F87j11 but it's not possible with the current 8 mhz oscillator. Any feedback would be helpful.

Thanks!

Ammar
  • 1,203
  • 5
  • 27
  • 64
  • When you send the AT&W command does the modem respond with "OK"? – Demetris Aug 20 '14 at 21:08
  • Yup, I think the gsm/gps module has a script (bootloader) that resets it or something to the default baudrate every few minutes. Here is a [picture](http://s17.postimg.org/uxzzd8yu5/baudrate.png) of the terminal going to bootloader mode, and that's when the baudrate changes to to 115200 or upon power reset. I just can't get any support from the module support team since they are in China. I don't know if the script is responsible for it or something else. I hope I didn't confuse you, if I did, let me know if you need further information. – Ammar Aug 20 '14 at 21:20
  • Every time the bootloader kicks in or the module is restarted, I have to open hyper-terminal (Putty) with 115200 baud-rate, then reprogram it to 19200. – Ammar Aug 20 '14 at 21:28
  • Why would you want to lower the Baud rate? Also, It may be my misunderstanding of HyperTerminal, but it doesn't actually 'alter' the baud rate (it only stays that way for the duration of it being open). HyperTerminal doesn't have the 'power' or 'authority' to change the baud rate permanently. – jbutler483 Aug 28 '14 at 12:48
  • @Ammar i've just read your last comment - i'm wondering, if you are 'able' to set it so it works (by setting the baud rate programmatic ally) - would it be possible (as a work around) to use a separate thread for setting it every so often by your program? – jbutler483 Aug 28 '14 at 12:59
  • Change the PIC 18F .. there are a lot of alternatives !! 18F4550 or other with right number of pins ! In my experience is better to improve the micro-controler, despite changing settings to other components, with poor documentation. – CristiC777 Sep 03 '14 at 08:44
  • Maybe it is a bug and it can be solved only by updating the firmware of the module. – j123b567 Sep 03 '14 at 13:23
  • By the way **HyperTerminal** is the name of a terminal emulation software that was included with some versions of Microsoft Widows. **Putty** is an open source ssh/telnet/serial client with terminal emulation. Please don't use the name of the software (**HypterTerminal** ) unless you are talking about the program that once was included with Microsoft Windows. – some Sep 04 '14 at 05:10
  • When reading the documentation I get the impression from section 2.26.1 that the modem (like most modems) is able to auto detect the data rate. After you have reset the modem, could you do a `AT+IPR?`. If it says 0 you have auto detect enabled, and the modem should auto detect that when you send `AT` to it. Could you also set **PuTTY** to 19200, reset the modem and then just type `AT` and press enter? Does the modem reply 'OK'? If so, the auto detect is working. When connected to the PIC, and after you reset the modem, do you wait enough time for the modem to reset? – some Sep 04 '14 at 05:11

4 Answers4

3

A possible workaround, (but probably not the best option), is to save your baud rate into the internal flash storage, and then have a separate thread that continuously sets the baud rate of your port.

OR A thread like;

while (true)
{
  MySerialPort.BaudRate = 19200; //this will set/update baud rate
  Thread.Sleep(30000); //this will sleep for 30 seconds 
}

Will save the Baud rate every 30 seconds;

First Example

Or going with my first example (where baud rate is saved to flash)

is that in your program startup, you read your internal flash storage, and from the value stored there you assign the baud rate.

As for setting the baud rate in HyperTerminal/etc - these are only 'temporary' baud rates - A bit like tuning a radio - you can hear different things from different baud rates - that's how hyperterminal works - it doesn't 'save' the baud rate, only assigns it for a temporary time (until you turn off and on your radio).

As for BootLoader, there should be a way of 'exiting' bootloader mode - have a look at your microcontrollers' documentation as it should only be on when you are updating your MC or 'Flashing' an update - not on constantly (Bootloader is like pressing the 'reset' button on your PC)!

jbutler483
  • 24,074
  • 9
  • 92
  • 145
2

Your attempt to fix baudrate by combining AT+IPR and AT&W is correct, but unfortunately it does not neccessarily work.


The AT&W command is actually not specified in any standard (see my question Which standard specifies the AT&W AT command?), so that means that exactly what is saved by AT&W is completely up to the manefacturer and you (unfortunately) cannot assume anything with regards to baudrate being saved or not.

Of course, if the manefacturer explicitly specifies that AT&W indeed does save baudrate, then you're good to go (for that specific device) but the document you linked does not even include AT&W in the list of commands... So when you test and find that your modem does not save baudrate, then that is an unfortunate fact that you have to accept.


When you say that it is not possible to change baudrate I assume you mean that the problem is that 8MHz is not easily dividable down to 115200 so that the error marging becomes non-negletible large like shown in the 8MHz table at WormFood's AVR Baud Rate Calculator, right?

The table indicates 7.8% error for 8MHz, but maybe the modem is tolerant in its reception? If one in X attempts succeed, that is all you need since the speed will be set to what you need, e.g. try AT+IPR=19200 at 115200 and then test AT at 19200. If successful, done, else try again. Maybe this will be good enough and resolve itself after a resonable time? I think it would be worth trying.

Alternatively you could perhaps try to write an interrupt routine to send out the start+data+stop bits for "AT+IPR=19200\r" at speed 115200 on a GPIO pin and connect just to see if it is possible that way to jumpstart the modem speed (see http://www.fpga4fun.com/SerialInterface2.html for calculations to step down frequency). You will probably need some additional electrical signal adaption for this as well and find some way of multiplexing GPIO and UART.

Community
  • 1
  • 1
hlovdal
  • 26,565
  • 10
  • 94
  • 165
-1

Not sure why you would need to alter the baud rate, especially since I think a lot of that would be driven by the connection dynamically, wouldn't it? It's been ages since I've done modem programming.

In any case, the poster Demetris did note the importance of AT&W - it's what actually gets the change to take. Think you need to have that in your script.

If this helps, this site at least documents some basic stuff you can do with this sort of modem. Likely you've already found it, but perhaps other readers have not!

http://smsiseasy.com/technicalinfo.html

TJ Bandrowsky
  • 842
  • 8
  • 12
-1

The command AT&W must be sent with the new baud rate. In other words, after having changed the baudrate to 19200 the modem is unable to go on receiving commands with the old speed. Try changing the host baudrate to 19200 before sending the AT&W command.

Power Engineering
  • 713
  • 14
  • 26