SerialDriver rx problem

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
pur300
Posts: 6
Joined: Tue Mar 10, 2015 11:22 pm

SerialDriver rx problem

Post 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?
User avatar
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

Post by Giovanni »

If it is a nucleo board then PA2 and PA3 are connected to the STLink.

Giovanni
pur300
Posts: 6
Joined: Tue Mar 10, 2015 11:22 pm

Re: SerialDriver rx problem

Post by pur300 »

i'm using a stm32f4 discovery board. Datasheet for this board states that pins PA2 and PA3 are free pins.
User avatar
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

Post by Giovanni »

It is possible that the RX signal is assigned to more than one pin, check board.h.

Giovanni
pur300
Posts: 6
Joined: Tue Mar 10, 2015 11:22 pm

Re: SerialDriver rx problem

Post 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.
User avatar
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

Post by Giovanni »

You cannot assign the same function to multiple pins, probably that is the problem.

Giovanni
pur300
Posts: 6
Joined: Tue Mar 10, 2015 11:22 pm

Re: SerialDriver rx problem

Post 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.
pur300
Posts: 6
Joined: Tue Mar 10, 2015 11:22 pm

Re: SerialDriver rx problem

Post 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.
User avatar
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

Post by Giovanni »

I have no elements to provide support.

Giovanni
pur300
Posts: 6
Joined: Tue Mar 10, 2015 11:22 pm

Re: SerialDriver rx problem

Post 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.
Post Reply