2012-02-24 03:36 AM
Hi all,
I'm searching to get work my UART4 port on my Discovery. I used the USART HyperTerminal_Interrupt example on stdPerif_example and I adapted to DISCOVERY. I see by some LedOn on the program that UART is working and sending interrupt. I manage to have a virtual USB-UART port with UM232R Ftdi but on my Putty nothing appeared I post my code /* USARTx configuration ------------------------------------------------------*/ /* USARTx configured as follow: - BaudRate = 9600 baud - Word Length = 8 Bits - Two Stop Bit - Odd 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_2; USART_InitStructure.USART_Parity = USART_Parity_Odd; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; STM_EVAL_COMInit(&USART_InitStructure); Function void STM_EVAL_COMInit(USART_InitTypeDef* USART_InitStruct) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable GPIO clock */ //RCC_AHB1PeriphClockCmd(UART4_TX_PIN | UART4_RX_PIN, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); //clock a PORTC RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE); //clock alla UART4! /* Connect PXx to USARTx_Tx*/ GPIO_PinAFConfig(GPIOC, GPIO_Pin_10, GPIO_AF_UART4); /* Connect PXx to USARTx_Rx*/ GPIO_PinAFConfig( GPIOC, GPIO_Pin_11, 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 configuration */ USART_Init(UART4, USART_InitStruct); /* Enable USART */ USART_Cmd(UART4, ENABLE); } I also add void UART4_IRQHandler(void); to _it.h to manage interrupt _it.c void UART4_IRQHandler(void) { if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET) { GPIO_SetBits(GPIOD, GPIO_Pin_14); // accende led /* Read one byte from the receive data register */ RxBuffer[RxCounter++] = (USART_ReceiveData(UART4) & 0x7F); if(RxCounter == NbrOfDataToRead) { /* Disable the UART4 Receive interrupt */ USART_ITConfig(UART4, USART_IT_RXNE, DISABLE); } } if(USART_GetITStatus(UART4, USART_IT_TXE) != RESET) { GPIO_SetBits(GPIOD, GPIO_Pin_13); // accende led /* Write one byte to the transmit data register */ USART_SendData(UART4, TxBuffer[TxCounter++]); if(TxCounter == NbrOfDataToTransfer) { /* Disable the UART4 Transmit interrupt */ USART_ITConfig(UART4, USART_IT_TXE, DISABLE); } } } Where I'm failing? THanks #uart/usart-parity-and-wordlengt2015-05-12 07:29 AM