Hi friends, I am trying to interface GSM with my ARM controller [stm32f103c8t6].
I knew a little about the working of GSM,
- By sending the "AT" command to GSM, it will respond with a "OK" message.
Before interfacing GSM with arm, i learned how to use HAL_uart function (generated from cube MX). I tried to transmit and receive data to "arm and terminal(pc)" , and it works good in HAL_uart function.
Problem:
- But when i connect to GSM with ARM, No response is getting from GSM.
- I tried another method, i use uart max232 with GSM to transmit and receive data it works fine. [sending data to pc terminal via max232].
I attached the uart communication diagram arm,gsm and max232.(I use max232 to communicate with pc since i have only st-link v2 which has no tx and rx).
Also the code generated from cube mx.
Check:
* what needs to be done prior to "AT" command communication. Maybe some special button press, timing after power up...
* voltage levels at UART lines. V_OH, V_OL at transmitter with V_IH, V_IL at receiver.
* UART settings. Baud rate, parameters like "8N1"...
Check:
* what needs to be done prior to "AT" command communication. Maybe some special button press, timing after power up...
* voltage levels at UART lines. V_OH, V_OL at transmitter with V_IH, V_IL at receiver.
* UART settings. Baud rate, parameters like "8N1"...
Check:
* what needs to be done prior to "AT" command communication. Maybe some special button press, timing after power up...
* voltage levels at UART lines. V_OH, V_OL at transmitter with V_IH, V_IL at receiver.
* UART settings. Baud rate, parameters like "8N1"...
V_OH, V_OL at transmitter and V_IH, V_IL at receiver GSM should not increase 2.8 v.
So i reduced the transmitter of the arm by 2.8 v [1 K and 5.7 K resistor as voltage divider] as specified in the GSM datasheet.
Datasheet [ pg : 26 ] : https://www.elecrow.com/download/SIM800C_Hardware_Design_V1.02.pdf
But When i connect GSM with max232 [uart]. It works fine.., By sending "AT" command from max232 to GSM, I am getting response to max232 as "OK" [In terminal].
The problem occur only when i replace my max 232 with arm. Arm receives "A" as a response from GSM.
Thank you for the response, the problem was solved almost..,
I use the interrupt for uart receive , now i am getting the response as "OK" from GSM.
But i am having a small problem in that, the received response i saved in the single variable which is a circular buffer.
For example:
uint8_t rx[10]; <-----receiving variable
- first response is "OK"
- second response is "Cpin ready"
- when i print my rx[10]........I get output as "OK Cpin ready"
No friend, i have changed the code slightly as i mentioned above(i use interrupt) and changed rx[] size.
I getting a small problem,
- Whenever i transmit to GSM as "AT", GSM will respond to arm as"OK" which will be stored in rx[] (since i used interrupt).
That is, rx[0-1] will have "OK"
- And when i transmit to GSM as "AT+CPIN?", GSM will respond to arm as "+CREG: 0,0 OK"
Now rx[2-14] has "+CREG: 0,0 OK"
But i want to start again from rx[0] for next response, how to overcome this.
By clearing buffer,emptying string ?????
Before you write the second command you should read Rx. The Rx_function should correct the read_pointer.
Then start the second command.
Then read the second response.
With a circular bufferyou have two pointers: read_pointer and write_pointer.
The read_function does not always start to read at rx(0). It starts to read at the read_pointer position.
At the vedy beginning it starts at 0.(OK)
At the next read it starts at 2.