Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed syslink DMA by guarding a none-atimic read. #1116

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

tobbeanton
Copy link
Member

The hangup of the syslink RX DMA read was due to that the USART_DMACmd function is not atomic and called from uartslkSendDataDmaBlocking as well as uartslkReceiveDMA which is run from an interrupt.

void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_USART_ALL_PERIPH(USARTx));
  assert_param(IS_USART_DMAREQ(USART_DMAReq));  
  assert_param(IS_FUNCTIONAL_STATE(NewState)); 

  if (NewState != DISABLE)
  {
    /* Enable the DMA transfer for selected requests by setting the DMAT and/or
       DMAR bits in the USART CR3 register */
    USARTx->CR3 |= USART_DMAReq;
  }
  else
  {
    /* Disable the DMA transfer for selected requests by clearing the DMAT and/or
       DMAR bits in the USART CR3 register */
    USARTx->CR3 &= (uint16_t)~USART_DMAReq;
  }
}

The USARTx->CR3 |= USART_DMAReq; translates to a read-modify-write operation and if the uart RX interupt happened just in the modify state it would write the wrong value to the register.

Syslink DMA RX will be used with only one byte payload as well as it tuns out to be more efficient.

Syslink DMA RX has been enabled again in kbuild.

@tobbeanton tobbeanton changed the title Fixed syslink DMA by guarding a none-atimic read. #1107 Fixed syslink DMA by guarding a none-atimic read. Sep 9, 2022
Copy link
Member

@evoggy evoggy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@tobbeanton tobbeanton merged commit 732713b into master Sep 9, 2022
@tobbeanton tobbeanton deleted the syslink_dma_fix branch September 9, 2022 14:37
@krichardsson krichardsson added this to the 2022.12 milestone Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants