2014-10-31 04:11 AM
I'm at wits end trying to figure out why exactly I can't transmit on UART4 or USART3.
The RX works, and i can receive data, however the TX pin is not working at all. Below is my configure code for UART4.void init_usart4(uint32_t baudrate) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE); /* GPIOA clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); /* GPIOA Configuration: USART2 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Connect USART1 pins*/ GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_UART4); GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_UART4); USART_InitStructure.USART_BaudRate = baudrate; 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_Tx | USART_Mode_Rx; USART_Init(UART4, &USART_InitStructure); USART_Cmd(UART4, ENABLE); // enable USART2}and in main i just loop and use ''USART_SendData(UART4, 'h');'' with a delayI've scoped the pin and nothing is coming out of it either I've changed out MCU's completely thinking I might've got a bad one but that hasn't fixed it either2014-10-31 04:19 AM
Hi
The only difference I can see between what you have and what I have in a project is : '' USART_Cmd( USART3, DISABLE );'' before the USART configuration Interrupts (NVIC) is configured for USART recieve I am using PortB same Portbits (10 & 11) and it works. Also, I have not found it but the USART peripheral probably needs to be taken out of reset (bit in RCC register somewhere)2014-10-31 05:00 AM
I've added in the disable as well as a deinit as well, still nothing.. this is getting frustrating
2014-10-31 06:11 AM
Should wait on TXE before writing out data. Write a constant stream of characters, look at the signal with a scope. Consider what circuitry you have connected to PC10.
2014-10-31 12:16 PM
I've added in waiting for the txe flag, still nothing, and i've already looked at it with a scope, nothing is coming out of the pin, the only thing attached to that pin is the RX of a rn-41 bluetooth module
and yes there is continuity between the Rx pin of the stm and the tx pin of the bluetooth moduleand yes i've removed the bluetooth and scoped the pin, still no output2014-10-31 01:21 PM
Code looks fine, the fact it doesn't work with either USART/UART configurations suggests you're not looking at the right pin, or the pin is shorted. Perhaps you can drive the pin high/low as a GPIO and confirm you can see that.