N
N
nemoforum2012-10-15 18:13:48
Do it yourself
nemoforum, 2012-10-15 18:13:48

STM32 and GPRS modem via USART

Good day to all!
Processor: STM32F100RB
Modem: GL868-DUAL
Task: sending every 30-60 seconds to the server a string like $IN,1210280001,00001,120831,112537,113540,0001250,4А&.

I continue to deal with STM32. I set up and raised USART, the data is running, everything is fine.
It came to managing the modem. Handles connect to GPRS, open a socket, transfer data, close the socket.
I write in C, which I study at the same time.
0. What is the best way to implement modem control?
1. Flow control - hardware or software?
2. How to receive and process responses and errors from the modem? Beating delays after each command is worthless.

Pieces of code, examples are welcome.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2012-10-16
@nemoforum

0. pieces of code - habrahabr.ru/post/139760/ - section "References". It is also worth downloading the library for Arduino - there is already work with GPRS, you can see the logic of work.
As for working with UART, I recommend reading mycontroller.ru/category/mikrokontrollereryi-stm32/usart/ You
should also read the forum for developers of cellular devices: electronix.ru/forum/index.php?s=655eb0cdb872286f07c344e441dfa245&showforum=130
1. Install the hardware.
2. When working with the modem, use waiting timeouts — wait for a response to your command no more than N seconds. It is also worth considering that in the finished product, a situation is possible in which your modem hangs corny, to be treated by juggling the power supply from the microcontroller. Those. don't count on the reliability of the modem and the fact that everything will work just as well in the end device as it does on your desk. Well, basic recommendations: do not forget to check the signal level (at + csq), the state of the gprs connection, etc ...

S
svd71, 2012-10-16
@svd71

The microcontroller has interrupts (or events) for receiving data via UART. This interrupt is triggered when the UART has received a byte. That is, you organize a receive buffer, fill it through this interrupt (event), and in the main loop (or by timer) check whether the buffer is empty or there is already something similar to the necessary data. If yes, then the data is processed and the buffer is cleared.
Exactly the same structure for sending. You also organize a buffer, you also do an interrupt (event). It only fires when a byte has already been transferred and it is necessary to continue transfers of the next byte.
In the main loop, only the send buffer is filled with some data and the first byte is sent.
I am not familiar with stm32, but read here and here .
In addition, find the datasheet of your controller - everything is usually chewed up there with code examples.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question