Page 1 of 1

SerialDriver rx problem

Posted: Sat Apr 04, 2015 2:29 pm
by pur300
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?

Re: SerialDriver rx problem

Posted: Sat Apr 04, 2015 2:33 pm
by Giovanni
If it is a nucleo board then PA2 and PA3 are connected to the STLink.

Giovanni

Re: SerialDriver rx problem

Posted: Sat Apr 04, 2015 2:36 pm
by pur300
i'm using a stm32f4 discovery board. Datasheet for this board states that pins PA2 and PA3 are free pins.

Re: SerialDriver rx problem

Posted: Sat Apr 04, 2015 2:42 pm
by Giovanni
It is possible that the RX signal is assigned to more than one pin, check board.h.

Giovanni

Re: SerialDriver rx problem

Posted: Sat Apr 04, 2015 3:11 pm
by pur300
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.

Re: SerialDriver rx problem

Posted: Sat Apr 04, 2015 3:14 pm
by Giovanni
You cannot assign the same function to multiple pins, probably that is the problem.

Giovanni

Re: SerialDriver rx problem

Posted: Sat Apr 04, 2015 3:28 pm
by pur300
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

Posted: Sun Apr 05, 2015 12:59 pm
by pur300
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.

Re: SerialDriver rx problem

Posted: Sun Apr 05, 2015 2:08 pm
by Giovanni
I have no elements to provide support.

Giovanni

Re: SerialDriver rx problem

Posted: Sun Apr 05, 2015 3:49 pm
by pur300
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.