cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 USART1 TX sending garbage

jf659
Associate II
Posted on March 21, 2014 at 15:03

Hello,

I am using the STM32F429 board, I have configured the USART1 for TX (PA9) and RX (PA10). For testing purposes i send a buffer of 0x44 values down the USART. I monitor this tranmission on another boards RX pin and print the result to the terminal (for testing purposes). However the USART1 is sending garbage and i am not receiving the 0x I don't think it is a problem with my code because it works perfectly on the STM32F407 when I loop RX and TX pin. Any suggestions to why I am receiving garbage? Thanks

void USART1_Configuration(void) 
{ 
/* Define the GPIO initial structure */ 
GPIO_InitTypeDef GPIO_InitStructure; 
/* Define the USART initial structure */ 
USART_InitTypeDef USART_InitStructure; 
/* Define the NVIC initial structure */ 
NVIC_InitTypeDef NVIC_InitStructure; 
/* GPIO Peripheral clock enable */ 
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); 
/* USART2 Peripheral clock enable */ 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); 
/* Configure PA9 and PA10 */ 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 
GPIO_Init(GPIOA, &GPIO_InitStructure); 
/* Configure the Tx and Rx pins for USART3 */ 
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); //TX 
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); //RX 
/* USART1 mode configure */ 
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_Mode = USART_Mode_Tx | USART_Mode_Rx; 
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 
/* Initialise and enable the USART1 */ 
USART_Init(USART1, &USART_InitStructure); 
/* enable the interrupt */ 
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); 
/* Enable the USART1 interrupt */ 
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; 
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; 
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 
NVIC_Init(&NVIC_InitStructure); 
USART_Cmd(USART1, ENABLE); 
} 
void USART1_IRQHandler(void) 
{ 
static int rx_index = 0; 
char aTextBuffer[50]; 
if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) // Received characters modify string 
{ 
rx_data[rx_index++] = USART_ReceiveData(USART1); 
if (rx_index >= (sizeof(rx_data) - 1)){ 
rx_index = 0; 
fin_flag = 1; 
} 
} 
} 

3 REPLIES 3
Posted on March 21, 2014 at 15:28

Any suggestions to why I am receiving garbage?

Two most probable reasons.

a) The HSE is 8 MHz and HSE_VALUE in the project, or PLL settings are not coherent with that. The EVAL series boards, and some files expect 25 MHz

b) The pins will not accept RS232 level, it expects 3V CMOS/TLL levels.

On the STM32F4-DISCO PA9 is unusable, should be fine on the STM32F429I-DISCO as I recall.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jf659
Associate II
Posted on March 21, 2014 at 16:00

Thank you very much clive. In the header file the HSE_VALUE was 25 MHz, I changed this to 8 MHz and it works perfect.

jf659
Associate II
Posted on March 21, 2014 at 16:01

Thank you very much clive. In the header file the HSE_VALUE was 25 MHz, I changed this to 8 MHz and it works perfect.