1

I ran into some issues configuring my stm32f429-DISCO board for a UART transmission on UART5. I used the example project provided by st. To be exact, the UART/UART_TwoBoards_ComDMA in version 1.7.0. In this example the USART1 is used to circle one data package around. When the DISCO-board is programmed with the original code, I can see the USART1 output message on my oscilloscope.

On the other hand, when I try the same thing with the UART5, because the pins for USART1 will be blocked in my final configuration it won't work.

I narrowed the problem down to the initialization process.

HAL_UART_MspInit(huart);

This function is not setting the TC and RXNE bit in UART1->SR, and therefore the UART5 is not configured. I know for UART1 you need to enable the clock, because it can be a synchronous transmission.

__HAL_RCC_USART1_CLK_ENABLE();

I can't seem to find a similar function for UART5. Has somebody an idea or a hint for me?

In case a bigger problem is underlying this issue, here are the changed settings for the UART5 configuration of the example.

/* Definition for USARTx clock resources */
#define USARTx                           UART5
//#define USARTx_CLK_ENABLE()            __HAL_RCC_USART1_CLK_ENABLE();
#define DMAx_CLK_ENABLE()                __HAL_RCC_DMA1_CLK_ENABLE()
#define USARTx_RX_GPIO_CLK_ENABLE()      __HAL_RCC_GPIOD_CLK_ENABLE()
#define USARTx_TX_GPIO_CLK_ENABLE()      __HAL_RCC_GPIOC_CLK_ENABLE() 

//#define USARTx_FORCE_RESET()           __HAL_RCC_USART1_FORCE_RESET()
//#define USARTx_RELEASE_RESET()         __HAL_RCC_USART1_RELEASE_RESET()

/* Definition for USARTx Pins */
#define USARTx_TX_PIN                    GPIO_PIN_12
#define USARTx_TX_GPIO_PORT              GPIOC
#define USARTx_TX_AF                     GPIO_AF8_UART5
#define USARTx_RX_PIN                    GPIO_PIN_2
#define USARTx_RX_GPIO_PORT              GPIOD
#define USARTx_RX_AF                     GPIO_AF8_UART5

/* Definition for USARTx's DMA */
#define USARTx_TX_DMA_CHANNEL            DMA_CHANNEL_4
#define USARTx_TX_DMA_STREAM             DMA1_Stream7
#define USARTx_RX_DMA_CHANNEL            DMA_CHANNEL_4
#define USARTx_RX_DMA_STREAM             DMA1_Stream0

/* Definition for USARTx's NVIC */
#define USARTx_DMA_TX_IRQn               DMA1_Stream7_IRQn
#define USARTx_DMA_RX_IRQn               DMA1_Stream0_IRQn
#define USARTx_DMA_TX_IRQHandler         DMA1_Stream7_IRQHandler
#define USARTx_DMA_RX_IRQHandler         DMA1_Stream0_IRQHandler
#define USARTx_IRQn                      UART5_IRQn
#define USARTx_IRQHandler                UART5_IRQHandler

I'm happy for any suggestion and help that guides me in the right direction.

Thank you for your time,

eimer

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
eimer
  • 81
  • 7
  • Read the reference manual about clocking (`RCC`). That has nothing to do with `USART` vs. `UART`, but the clock to the peripherals. **All** peripherals in current MCUs are synchronous, thus need a clock. That is in **no way** related to their function. (Oh, and: it would be easier to use the hardware directly and avoid that crappy ST bloatware, btw.) – too honest for this site Aug 06 '15 at 15:32
  • 1
    You might also take a look at ST's new Cube tool: http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1533/PF259242?sc=stm32cube So far, I've found this utility to be helpful in troubleshooting pin assignments. – Throwback1986 Aug 06 '15 at 16:24
  • @Olaf My clock configuration is solid, using the different timer for a while now and I get exactly what I ask for in terms of timings. – eimer Aug 07 '15 at 07:02
  • 1
    @Throwback1986: I know the tool quite well, as long as you don't use it for productive code export, but perfect for trouble shooting e.g. for pins. Thanks anyway. – eimer Aug 07 '15 at 07:17
  • @eimer: You seem not to have understood what I meant. I do not talk about the system time or RTC, but the clocking tree (so far for "forest") and the clock for the peripheral. – too honest for this site Aug 07 '15 at 12:46
  • @Olaf Just in case you are talking about that: http://i.stack.imgur.com/VZZBx.jpg we are talking about the same thing I guess. The timers where just an example, that the configuration of the rcc is done properly. Sorry, for the misleading comment. – eimer Aug 10 '15 at 07:33

1 Answers1

0

UART5 has no S, so the function to enable the clock is called __HAL_RCC_UART5_CLK_ENABLE();, like e.g. there: Receiving data from 2 UARTs, STM32F4-Discovery, HAL drivers

Community
  • 1
  • 1
  • Exactly what I was searching for, but couldn't find. Sometimes you don't see the tree in the forest. Thank you. – eimer Aug 07 '15 at 07:00