Question
UART4 on STM32F417
Posted on March 01, 2013 at 16:25
Hi Guys,
After reading the whole of Google and finding this thread (https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2F[STM32F4-Discovery]%20UART4%20Problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=4749) I'm with my hands in my hair :) I can't get the UART4 to be working.... My Source code: void Usart_Printf(void) { usart_init(); /* Output a message on Hyperterminal using printf function */ printf(''\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r''); } void usart_init(void) { /* USARTx configured as follow: - BaudRate = 115200 baud - Word Length = 8 Bits - One Stop Bit - No parity - Hardware flow control disabled (RTS and CTS signals) - Receive and transmit enabled */ GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; /* Enable GPIO clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); /* Enable UART clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE); /* Connect PXx to USARTx_Tx*/ GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_UART4); /* Connect PXx to USARTx_Rx*/ GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_UART4); /* Configure USART Tx as alternate function */ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Configure USART Rx as alternate function */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_Init(GPIOC, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = 115200; 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 configuration */ USART_Init(UART4, &USART_InitStructure); /* Enable USART */ USART_Cmd(UART4, ENABLE); } I think all the ports are OK (in the datasheet, 2 AF ports are mentioned for the UART4, (PA0,PA1 and PC10 and PC11), which I also don't get... Can anyone help me? Thanks guys (I guess Clive will answer this one? ;) )