5
votes

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!

4
When you send the AT&W command does the modem respond with "OK"?Demetris
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 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
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
Any suggestion guys?Ammar
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

4 Answers

3
votes

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)!

2
votes

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.

-1
votes

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

-1
votes

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.