2011-07-06 02:26 AM
USART2 on ComStick (STM32F107)
2011-07-06 05:57 AM
You have a question?
http://www.catb.org/~esr/faqs/smart-questions.html#before
2011-07-06 07:28 AM
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?
2011-07-06 08:58 AM
Make sure you enable the APB clocks for USART2, GPIOD and AFIO. The latter is required for remapping to work.
2011-07-12 02:48 AM
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