Question
STM32F207VGT6 UART configuration error
my UART settings are as follows:
void USART_Configuration(EUartCom uartCom)
{
USART_Config(uartCom, COM_BAUDRATE[uartCom]);
}
void USART_Config(EUartCom uartCom, uint32_t baudrate)
{
USART_DeInit(COM_USART[uartCom]);
GPIO_InitTypeDef GPIO_InitStructure;
// DE:
GPIO_InitStructure.GPIO_Pin = COM_DE_PIN[uartCom];
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(COM_DE_PORT[uartCom], &GPIO_InitStructure);
GPIO_ResetBits(COM_DE_PORT[uartCom], COM_DE_PIN[uartCom]);
// TX:
GPIO_InitStructure.GPIO_Pin = COM_TX_PIN[uartCom];
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(COM_TX_PORT[uartCom], &GPIO_InitStructure);
// RX:
GPIO_InitStructure.GPIO_Pin = COM_RX_PIN[uartCom];
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(COM_RX_PORT[uartCom], &GPIO_InitStructure);
// AF:
GPIO_PinAFConfig(COM_TX_PORT[uartCom], COM_TX_PIN_SOURCE[uartCom], COM_AF[uartCom]); // TX
GPIO_PinAFConfig(COM_RX_PORT[uartCom], COM_RX_PIN_SOURCE[uartCom], COM_AF[uartCom]); // RX
// USART
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = baudrate;
USART_InitStructure.USART_WordLength = COM_WORD_LENGTH[uartCom];
USART_InitStructure.USART_StopBits = COM_STOP_BITS[uartCom];
USART_InitStructure.USART_Parity = COM_PARITY[uartCom];
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(COM_USART[uartCom], &USART_InitStructure);
// RXNE Enable
USART_ITConfig(COM_USART[uartCom], USART_IT_RXNE, ENABLE);
// IDLE Enable
USART_ITConfig(COM_USART[uartCom], USART_IT_IDLE, ENABLE);
// USART
USART_Cmd(COM_USART[uartCom], ENABLE);
}
UART setting by getting defined value.
uint32_t COM_BAUDRATE[COMn] = {76800, 57600, 38400, 115200};
USART_Configuration(COM0);
USART_TX_DMA_Init(COM0);
USART_SetDE(COM0, serialRx);
USART_Configuration(COM1);
//USART_Config(COM1, 57600);
USART_TX_DMA_Init(COM1);
USART_SetDE(COM1, serialTx);
USART_Configuration(COM2);
USART_TX_DMA_Init(COM2);
USART_SetDE(COM2, serialTx);At this time, 'USART_Configuration' is not set,
but 'USART_Config(COM1, 57600)' is operate OK. ;(
Why is this happening?
This code(USART_Configuration) works on STM32F207VG 144pin is OK, but does't work on 100pin chip.
USART1, 3 is OK.
USART2 is problem;
