cancel
Showing results for 
Search instead for 
Did you mean: 

UART4 Unavailable on STM32F750N8-DK?

DRobe.4
Senior

I want to use only the Tx pin on UART4, it is on PA0/CN5-1 of the Arduino connector. I setup

// Initialize UART4 for Debug Terminal 250 kbaud using 50 MHz PCLK1 /////////////////////////////////

   PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_TIM

                                                                  |RCC_PERIPHCLK_USART1

                                                                  |RCC_PERIPHCLK_USART6

                                                                  |RCC_PERIPHCLK_UART4;               // enable clocks to USART1/USART6/UART4/TIM

 PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;      // USART1 runs on PCLK2 = 100 MHz

 PeriphClkInitStruct.Usart6ClockSelection = RCC_USART6CLKSOURCE_PCLK2;      // USART6 runs on PCLK2 = 100 MHz

 PeriphClkInitStruct.Usart6ClockSelection = RCC_UART4CLKSOURCE_PCLK1;      // USART4 runs on PCLK1 = 50 MHz

 PeriphClkInitStruct.TIMPresSelection    = RCC_TIMPRES_ACTIVATED;

   RCC->APB1ENR |= RCC_APB1ENR_UART4EN;

      __HAL_RCC_GPIOA_CLK_ENABLE();

      GPIO_InitStruct.Alternate = GPIO_AF8_UART4;

      GPIO_InitStruct.Mode       = GPIO_MODE_OUTPUT_PP;            // PA0=Tx

      GPIO_InitStruct.Pin        = GPIO_PIN_0;

      GPIO_InitStruct.Pull       = GPIO_NOPULL;

      GPIO_InitStruct.Speed      = GPIO_SPEED_MEDIUM;

      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

   UART4->CR1   = 0x00;                                       // reset

   UART4->BRR  = 400;                                          // 100,000,000/2/250000=200 (running on PCLK1 = 50 MHz)

      UART4->CR1  = 0x1008;                                                   // Enable Tx and 9-bit length using bit12=1

      UART4->CR1 |= USART_CR1_UE;                                          // Enable UART4

When I observed CN5-1 on a scope, no sign of activity.

To debug further, I went to STM32CubeMX and tried to enable UART4 and it was unavailable even though I ensured that no ADC/SDMMC/ETH were enabled. I am using the LCD but it should not conflict. What am I doing wrong?

3 REPLIES 3

GPIO_InitStruct.Mode       = GPIO_MODE_AF_PP;  

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DRobe.4
Senior

Thanks, but that had no effect. Maybe the answer involves the peculiar CubeMX unavailability of UART4... other USARTs work. BTW, just in case I wasn't clear, my Keil IDE does not object to the code. Also, the code that I pasted above is only a small part of the whole code, so my next step is to delete everything unrelated to UART4... I was hoping that there was a really simple solution.

DRobe.4
Senior

The stripped down version works, so there was some conflict, I guess.