AnsweredAssumed Answered

STM32F407 collision between ethernet and DMA

Question asked by Vaclav Chrascina on Apr 24, 2018

Hello,

I am continuously sending and receiving data throught DMA. It's working like I expect so I added Ethernet and LwIP in my MXCube project and compiled. Everything works fine until I plug LAN cable. Could you give me some advice what am I doing wrong or what setting did I forget about?

 

Here is my code:

int main(void)
{

 

  HAL_Init();

 

  SystemClock_Config();

 

  MX_GPIO_Init();
  MX_DMA_Init();
  MX_LWIP_Init();
  MX_USART3_UART_Init();
 
  HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_SET);                //set RS 485 into transmit mode
    
  HAL_UART_Transmit_DMA(&huart3, aTxBuffer, 2);
  HAL_UART_Receive_DMA (&huart3, aRxBuffer, 4);

 

  while (1)
  {
  }
}

 

static void MX_USART3_UART_Init(void)
{

 

  huart3.Instance = USART3;
  huart3.Init.BaudRate = 38400;
  huart3.Init.WordLength = UART_WORDLENGTH_9B;
  huart3.Init.StopBits = UART_STOPBITS_1;
  huart3.Init.Parity = UART_PARITY_EVEN;
  huart3.Init.Mode = UART_MODE_TX_RX;
  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart3.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart3) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

 

}

 

static void MX_DMA_Init(void)
{
  /* DMA controller clock enable */
  __HAL_RCC_DMA1_CLK_ENABLE();

 

  /* DMA interrupt init */
  /* DMA1_Stream1_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn);
  /* DMA1_Stream3_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);

 

}

 

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle)
{
    __NOP();
  /* Set transmission flag: transfer complete */
    HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_RESET);                    //RS 485 receive mode
    //DataRecieved = 0;
    UartReady = SET;
}

 

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{
    __NOP();
  /* Set transmission flag: transfer complete */
    HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_SET);                        //RS 485 transmit mode
    //DataRecieved = 1;
    UartReady = SET;
    HAL_UART_Transmit_DMA(&huart3, aTxBuffer, 2);
}

Outcomes