USART1 on the Board STM32VLDiscovery do not want to work, no matter what tricks?

0 like 0 dislike
Hi all. I cut a small programme under STM32VLDiscovery STM32 on the Board and I needed to output debug data via USART1. The problem is that USART1 is working. At all(.

I connected insights USART'and (PA9, PA10) through UART<->COM Converter FT232RL to the computer. He USART1 initialize with the following code:
void debug_init() { GPIO_InitTypeDef GPIO_RxTx_InitStruct; USART_InitTypeDef USART_InitStruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); GPIO_RxTx_InitStruct.GPIO_Speed = GPIO_Speed_10MHz; GPIO_RxTx_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_RxTx_InitStruct.GPIO_Pin = GPIO_Pin_9; /* PA9 = TX */ GPIO_Init(GPIOA, &GPIO_RxTx_InitStruct); GPIO_RxTx_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_RxTx_InitStruct.GPIO_Pin = GPIO_Pin_10; /* PA10 = RX */ GPIO_Init(GPIOA, &GPIO_RxTx_InitStruct); USART_DeInit(USART1); USART_StructInit(&USART_InitStruct); USART_InitStruct.USART_BaudRate = 115200; USART_InitStruct.USART_WordLength = USART_WordLength_8b; USART_InitStruct.USART_StopBits = USART_StopBits_1; USART_InitStruct.USART_Parity = USART_Parity_No; USART_InitStruct.USART_Mode = USART_HardwareFlowControl_None; USART_InitStruct.USART_HardwareFlowControl = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART1, &USART_InitStruct); USART_Cmd(USART1, ENABLE); }

As you can see, I use the standard library peripherals from ST for STM32.

The sequence for initialization USART'a standard in the extreme:
  • Serves the clock signal to the module USART1 and GPIOA;
  • Initialize appropriately the legs PA9 and PA10;
  • Initialize USART1 and allow it to work.

Data transfer (in my case I am passing the same symbol) is the following code (wait until the module will not be ready to send next character and pass the desired character):
void debug_putchar(char ch) { while (!USART_GetFlagStatus(USART1, USART_FLAG_TC)) {} USART_SendData(USART1, (uint16_t) ch); }

In the main function these two functions are used:
debug_init(); while (1) { debug_putchar('h'); }

That's the whole code. On the conclusion with the STM32VLDiscovery I look through the utility minicom on the PC. But with the Board not output any single character. Watched the voltage at terminal TX — of the arrow is always at zero. The contact between the pins PA9, PA10 and the terminal of the transmitter UART<->COM is — checked.

Shoveled the results of Google — all the same code and all it works. I have the same — somehow, the silence in the serial channel.

I may have the evening already blurry eyes. Why this thing doesn't work and what to do?

UPD: thank you All. The problem was solved.

First, I mixed up a couple of assignments in the structure of the USART_InitStruct. You need to make it so:
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

not like me... Thanks to the unknown well-wisher who wrote to me in gugliotta and drew my attention to this error.

Secondly, it was very stupid to connect the output of the Tx UART<->COM Converter in the Tx output from the STM32. And to do the same even with the output Rx. Rearranged — all earned.

Indeed, the morning is wiser than evening).
by | 4 views

1 Answer

0 like 0 dislike
Um, actually, when there is no transmission line TX/RX should be attracted to one. And have an oscilloscope to look at.

Related questions

0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Jun 7, 2019 by iDraeam94i
110,608 questions
257,186 answers
32,702 users