Hi, I am having trouble getting my USART6 receive on PORT PC7 working.
I have USART6 initialized at 115200 baud in TX and RX mode and can transmit fine on USART6 PORT PC6. In order to test USART6 reception I have a simple forever polled loop which echoes the USART6 received bytes onto my debug port which is UART7. UARt7 Transmit works fine. but I do not see any data coming in on USART6 which is coming from a GPS receiver, verified by monitoring the incoming data in another serial terminal window.
My echoing loop is as follows:
// Do we have a received character in USART6?
if ((USART6->ISR & USART_ISR_RXNE) == USART_ISR_RXNE)
// Then transmit it on the Debug port, UART7.
uint8_t receivedByte = (uint8_t)(USART6->RDR & 0xFF); // This also clears the USART_ISR_RXNE bit.
// Loop until transmit data register is empty
while (!(UART7->ISR & USART_FLAG_TXE));
UART7->TDR = (uint32_t)receivedByte;
My initialization code is here:
void InitGPSUARTTx(uint32_t baudRate)
// Enable USART6 clock
RCC->APB2ENR |= RCC_APB2ENR_USART6EN;
// Configure PC6 USART6 TX as alternate function I/O for USART6
GPIOSetAltFunc(GPSUART6GPIO, GPSUART6TxOutPin | GPSUART6RxInPin, GPIO_PuPd_NOPULL, GPIO_OType_PP, GPIO_AF8_USART6);
USART_SetConfig(USART6, USART_MODE_TX_RX, baudRate);
// UART6 default clock is from PCLK1 which is initially set to 54MHz
// because of the initial half speed 108MHz AHB/PHB busses.
// Those bus speeds are later increased to 216MHz in InitSDCard()
// after the SD card initialization at the lower bus speed.
// Set GPS USART6 BRR register for 108MHz / 115200.
// this gives a better match to 115200 than the computed value from USART_SetConfig()
// This value has been determined experimentally by measuring the actual transmission rate.
USART6->BRR = 938;
// Enable USART6
USART6->CR1 |= USART_CR1_UE;
The GPIOSetAltFunc() and USART_SetConfig() are my own functions that have been widely proven elsewhere in my application to simply set the AF modes for GPIO pins and also a simplified USART Config, that originally derived from the STD periph lib.
Am I missing something obvious here? Any help is appreciated, thanks.