Hello,
I would like to include a gsm module into my project but i have an issue with a SerialDriver. Gsm module is connected to a stm32f4 via usart2 interface and it uses PA2 and PA3 pins for communication. When i send a command string to the gsm module everything works ok, the gsm module receives my command and it responds accordingly. The problem is that when i want to read the response i get an empty string, even if the response is clearly seen with a help of a logic analyzer. I have set a pin mode for PA2 and PA3 as an alternate function 7(according to a datasheet), output type pushpull, speed 50mhz and i also turned on pull up resistors.
What could be a problem?
SerialDriver rx problem
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: SerialDriver rx problem
If it is a nucleo board then PA2 and PA3 are connected to the STLink.
Giovanni
Giovanni
Re: SerialDriver rx problem
i'm using a stm32f4 discovery board. Datasheet for this board states that pins PA2 and PA3 are free pins.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: SerialDriver rx problem
It is possible that the RX signal is assigned to more than one pin, check board.h.
Giovanni
Giovanni
Re: SerialDriver rx problem
I checked a datasheet and i figured out that besides pin PA3, there is also a pin PD6 assigned to a usart2_rx. Pin PD6 has an alternate function 0 set in a board file.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: SerialDriver rx problem
You cannot assign the same function to multiple pins, probably that is the problem.
Giovanni
Giovanni
Re: SerialDriver rx problem
I connected only pins PA2 and PA3 with a usart2(alternate function 7). Pins such as PD6 and PD5 which can also be used for usart2 are not connected with usart2(they don't have an alternate function set). I am going to try a sdReadTimeout() function with a timeout set to one second and see if i am going to get a response back.
Re: SerialDriver rx problem
I tried to use usart3 instead of usart2 and the problem is still present. I tried to read a response with an sdReadTimeout() function into a buffer and noticed that the return value of the function is always 10. The content of a buffer is not a proper response value(\r\nOK\r\n) but a weird string which contains 10 ascii characters with an ordinal number 127.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: SerialDriver rx problem
I successfully resolved a problem. The problem was that i forgot to set the number of stop bits in the cr2 register. Thank you for your help.