2012-01-25 08:07 PM
Got freertos running on Discovery board STM32F4
Following is function which initializes USART, but i see only garbage coming out hyper terminal, void xSerialPortInitMinimal(unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) { USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; /* Create the queues used to hold Rx/Tx characters. */ xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) ); xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) ); /* If the queue/semaphore was created correctly then setup the serial port hardware. */ if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) ) { /* Enable USART2 clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); /* Connect PD5 and PD6 pins to AF */ GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_USART2); GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_USART2); /* Configure LED USART2 Tx (PD5) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init( GPIOD, &GPIO_InitStructure ); /* Configure USART2 Rx (PD6) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_Init( GPIOD, &GPIO_InitStructure ); USART_InitStructure.USART_BaudRate = 230400; 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; USART_Init( USART2, &USART_InitStructure ); USART_ITConfig( USART2, USART_IT_RXNE, ENABLE); USART_ITConfig( USART2, USART_IT_TXE, ENABLE); NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configMAX_CO_ROUTINE_PRIORITIES; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init( &NVIC_InitStructure ); USART_Cmd( USART2, ENABLE ); } }2012-01-26 08:39 AM
The initialization looks reasonable.
Try a lower baud rate. Try measuring the baud rate on a scope to confirm the correct/expected bit time. Try a different serial port or usb dongle. Try using 2 stop bits. Try sending a known character, in place of whatever is in your output buffers. Try a simple stand-alone application sending data to the USART. Don't enable, or keep enabled, the TXE interrupt if you have no data to send. Don't see the transmit code. HyperTerminal sucks, try something like TeraTerm or RealTerm.2012-01-26 10:24 AM
Tried and it works great now, Thanks for help. It was not aware of Crystal speed (8MHZ).
2012-02-05 11:34 PM
Can you detail your fix please ?
I have the same problem with freeRtos . Thanks2012-02-06 08:05 AM
Baud rate issues are almost always due to a disparity between the physical hardware, and the software settings.
Make sure your IDE knows what CPU is being used, and what frequency it is being clocked with. Check the HSE_VALUE definition. If the chip is running at 16 MHz, but the software defines it as 8 MHz, the actual baud rate will be double, assuming that the PLL settings don't exceed the operating limits. Want to confirm the baud rate, then stick a scope on the transmit pin and measure the bit timings.2012-02-06 10:10 AM
Use Discovery board setting for PLL, as some one right issue with cystal.
2012-04-23 07:10 AM
Hi, I have a problem to set usart baud rate to 921.6 k value.
I work on Discovery board STM32F4. does anybody have any ideas about it??any help is very appreciate!! :)2012-04-23 08:33 AM
Hi, I have a problem to set usart baud rate to 921.6 k value.
I work on Discovery board STM32F4. does anybody have any ideas about it??any help is very appreciate!! :)
Can you be more specific about what kind of problem this is? Can you not set it? Are the bit timings wrong? Have you tried 8 vs 16 oversampling? What frequency are you running the bus at? A lot of RS232 stuff used to filter a ~1Mbit
2012-04-30 01:26 AM