2013-03-08 01:46 AM
hi,
I'm working with the stm3210c_eval and I would like to use the UART5 . this is the configuration void UART5_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; /* Clock configuration -------------------------------------------------------*/ /* Configure the GPIO ports( UART5 Transmit and Receive Lines) */ /* Configure the UART5_Tx as Alternate function Push-Pull */ /* Configure UART5_Tx as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Configure UART5_Rx as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); /* UART5 configuration ------------------------------------------------------*/ /* UART5 configured as follow: - BaudRate = 9600 baud - Word Length = 8 Bits - One Stop Bit - No parity - Hardware flow control disabled (RTS and CTS signals) - Receive and transmit enabled */ 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_Rx | USART_Mode_Tx; /* Configure the UART5 */ USART_Init(UART5, &USART_InitStructure); /* Enable UART5 interrupt */ USART_ITConfig(UART5, USART_IT_RXNE, ENABLE); /* Enable the UART5 */ USART_Cmd(UART5, ENABLE); } I can send and recieve data. my problem is that I recieve a wrong data and the same when I send.2013-03-08 06:57 AM
Do the pins conflict? PC12 SPI3_MOSI, PD2 MC_NTC
Do other USART's work properly? What do the wave forms look like, does that explain the corruption? Or suggest the baud clock is wrong? Rate issues with STM32 parts general relate to a disagreement in software and hardware about what the HSE clock is. Check the definition of HSE_VALUE for the project, the HSE on the board, and how the PLL is set.2013-03-08 07:33 AM
U
ART5 no2013-03-08 09:17 AM
Ok, so HSE and the core clock is fine.
What do the signals look like in this failing condition. What is the test? You'll need to post some more complete code that demonstrates the configuration and failure/success. ie a stand alone app framework that shows USART1, USART2 and UART5. Are there board level conflicts? Can you do a simple loop back of Tx and Rx and see the problem, of is the issue more external?2013-03-13 03:02 AM
this is the configuration in my project :
void RCC_configuration(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA \ | RCC_APB2Periph_GPIOB \ | RCC_APB2Periph_GPIOC \ | RCC_APB2Periph_GPIOD \ | RCC_APB2Periph_AFIO \ | RCC_APB2Periph_USART1, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE); } void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; /////////////*********usart1 *//////////// /* Configuring USART1_Tx as 'alternate function push-pull' */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configuring USART1_Rx as 'input floating' */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); /////////////*********usart5 *//////////// /* Configuring USART5_Tx as 'alternate function push-pull' */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Configuring USART5_Rx as 'input floating' */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); } void USART_configuration(void) { USART_InitTypeDef USART_InitStructure; GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable ,ENABLE); /* USARTx configured as follow: - BaudRate = 9600 baud - Word Length = 8 Bits - One Stop Bit - No parity - Hardware flow control disabled (RTS and CTS signals) - Receive and transmit enabled */ 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_Rx | USART_Mode_Tx; STM_EVAL_COMInit(COM1, &USART_InitStructure); /* Configure the USART1 */ USART_Init(USART1, &USART_InitStructure); /* Enable the USART Receive interrupt */ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //USART_ITConfig(USART1, USART_IT_TXE, ENABLE); USART_Cmd(USART1, ENABLE); /* Configure the USART5 */ USART_Init(UART5, &USART_InitStructure); /* Enable the USART Receive interrupt */ USART_ITConfig(UART5, USART_IT_RXNE, ENABLE); //USART_ITConfig(USART1, USART_IT_TXE, ENABLE); USART_Cmd(UART5, ENABLE); } void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; /* Place the vector table into FLASH */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); /* Configure the NVIC Preemption Priority Bits */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); /* Enabling interrupt from USART1 */ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Enabling interrupt from USART2 */ NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_Init(&NVIC_InitStructure); /* Enabling interrupt from USART5 */ NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn; NVIC_Init(&NVIC_InitStructure); } after debug (see attachement). when I connect PC12 with PD2 (UART5)and I send a uint16_t I receive it correctly. but when I use hyperterminal or putty i receive a wrond data. ________________ Attachments : usart5.bmp : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtXB&d=%2Fa%2F0X0000000aRO%2FiDwse3OAdecq4LIFhqne5CDwP82fQcGlZdlB1QH19jw&asPdf=false2013-03-13 05:08 AM
The code looks ok, lose the STM_EVAL_COMInit(COM1, &USART_InitStructure);
The loop back works, so assume the issue probably isn't the STM32. Consider now how you have this wired up to the PC. You don't describe this, but you will need a MAX232 type device with the correct capacitors, to convert the CMOS level signals into RS232 levels for that interface. What do the signals look like at the PC end of the interface, do you have a scope, have you checked any of this? How have you addressed the PC12 conflict with SPI3_MOSI, and PD2 MC_NTC on the board?