Question
USART Rx problem
Posted on February 13, 2012 at 20:16
Hello,
I have a little problem with Rx on stm32f417.I designed my own board, byt i am putting this here, becouse i cannot find another approperiate forum.I tried to set up UART2, but i cannot make reciving working.HW is OK, i tested that.void USART_Inicializace(void){ GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitTypeDef GPIO_InitStructure2; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); // 1. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE); // 2. GPIO_PinAFConfig ( GPIOD, GPIO_PinSource5 , GPIO_AF_USART2) ; GPIO_PinAFConfig ( GPIOD, GPIO_PinSource6 , GPIO_AF_USART2) ; // // // Tx GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; // alternate function! GPIO_InitStructure.GPIO_OType = GPIO_OType_PP ; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure);////// // Rx GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_Init(GPIOD, &GPIO_InitStructure);// 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; USART_Init(USART2, &USART_InitStructure);// USART_Cmd(USART2, ENABLE); // jeste zbyva konfigurace preruseni// NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//// NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;// NVIC_Init(&NVIC_InitStructure);// USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);}Thank you.