UART4 support on STM32F103

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

UART4 support on STM32F103

Post by alexblack »

Hello.
When I tried to compile project with STM32_UART_USE_UART4 option setted to TRUE I received this message:

Code: Select all

UART4 DMA access not supported in this platform

I studied datasheets and driver code but have not found anything that would interfere with its work. When I disabled this error message my code starts to work fine.
Tell me please what is the reason to not to support UART4 on STM32F103 ?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: UART4 support on STM32F103

Post by Giovanni »

Hi,

It is because DMA2 channels 4 and 5 have a shared IRQ on XL devices that would create conflicts among drivers using those channels (UART and SDIO, we rated SDIO rated more important).

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: UART4 support on STM32F103

Post by alexblack »

Thank you.
I understand that the only place where it is possible - it is dmaStreamRelease(..) function:

Code: Select all

/* Disables the associated IRQ vector.*/
  nvicDisableVector(dmastp->vector);

Maybe just need to add some logic to this case? Or there are still places that I have not found?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: UART4 support on STM32F103

Post by Giovanni »

Allocation and release of channels are not related to the problem.

The problem is that the ISR would have to be shared between UART and SDIO drivers so it should be placed in a shared file of some kind.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: UART4 support on STM32F103

Post by alexblack »

Hi, but if I understood right - this is done already in file stm32_dma.c. This is shared file for both drivers, isn't it? The drivers not use direct ISR - it uses callbacks.

Code: Select all

 file: "stm32_dma.c"
...
/**
 * @brief   DMA2 streams 4 and 5 shared interrupt handler.
 * @note    This IRQ is shared between DMA2 channels 4 and 5 so it is a
 *          bit less efficient because an extra check.
 *
 * @isr
 */
CH_IRQ_HANDLER(DMA2_Ch4_5_IRQHandler) {
  uint32_t flags;

  CH_IRQ_PROLOGUE();

  /* Check on channel 4.*/
  flags = (DMA2->ISR >> 12) & STM32_DMA_ISR_MASK;
  if (flags & STM32_DMA_ISR_MASK) {
    DMA2->IFCR = flags << 12;
    if (dma_isr_redir[10].dma_func)
      dma_isr_redir[10].dma_func(dma_isr_redir[10].dma_param, flags);
  }

  /* Check on channel 5.*/
  flags = (DMA2->ISR >> 16) & STM32_DMA_ISR_MASK;
  if (flags & STM32_DMA_ISR_MASK) {
    DMA2->IFCR = flags << 16;
    if (dma_isr_redir[11].dma_func)
      dma_isr_redir[11].dma_func(dma_isr_redir[11].dma_param, flags);
  }

  CH_IRQ_EPILOGUE();
}
...

As a result UART4 driver works alone at least.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: UART4 support on STM32F103

Post by Giovanni »

You may give it a try, that check was added when the DMA handling was not yet centralized. I don't remember if there is some other reason hidden there.

Giovanni
Post Reply