cancel
Showing results for 
Search instead for 
Did you mean: 

USART2 on ComStick (STM32F107)

lucio2
Associate II
Posted on July 06, 2011 at 11:26

USART2 on ComStick (STM32F107)

4 REPLIES 4
Posted on July 06, 2011 at 14:57

You have a question?

http://www.catb.org/~esr/faqs/smart-questions.html#before

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
lucio2
Associate II
Posted on July 06, 2011 at 16:28

yes.. there was... but somehow i deleted. i explain it again:

i would like to use usart2 on this device; in particular i choosed the configuration on PORTD remapped from pins 3 to 7. Here's my code:

 GPIO_InitTypeDef GPIO_InitStructure; //Pin TX GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOD, &GPIO_InitStructure); //Pin RX GPIO_PinRemapConfig(GPIO_Remap_USART2,ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); 
 USART_InitTypeDef USART_InitStructure; USART_DeInit(USART2); 
 USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; USART_Init(USART2, &USART_InitStructure); 
 USART_Cmd(USART2, ENABLE); 
 
 

Then periodically i use

USART_SendData(USART2,c)

to send the c character. I'm not sure if this init code is right, because i'm new of STM world, and i would like some advice. Moreover, i tried to scope the TX pin and i saw only a constant 3.3voltage. I mean.. is this correct?
Posted on July 06, 2011 at 17:58

Make sure you enable the APB clocks for USART2, GPIOD and AFIO. The latter is required for remapping to work.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
lucio2
Associate II
Posted on July 12, 2011 at 11:48

apb1 for usart2 and apb2 for gpiod and afio were enabled. The problem was that i'm a douche :D, because i tried to scope the output with a simple tester, not considering that with 9600bps i could not see anything different than 3.3V;

Now another question if you don't mind: i would like to connect the comstick to a gsm module via uart. Electrical features of the module require CMOS 2.8V, and i read on stm32f107 datasheet that gpio are compliant with TTL and CMOS. So electrically i think that they can be connected directly without any serial level converter. So i did... but it does not work. Consider that the gsm module ha autorate, so i exclude problems about rating, stopbit, parity, etc..

Have you any ideas of what could be the problem? Thx in advantage