Skip to content

Nucleo_F412_W5100S_Test

Nucleo_F412_W5100S send udp data

teddy

Published November 20, 2023

96 UCC

8 WCC

35 VAR

Nucleo_F412_W5100S_Test

Components

Hardware components

x 1


x 1


Project description

HardWare Set

Nucleo-F412

W5100S-shield

HW config

Project Set

PIN Config

PIN config

CLK Config

CLK config

GPIO Config

GPIO config

SPI Config

Parameter Settings

SPI Parameter config

DMA Settings

SPI DMA config

Program Seq

Program Diagram

Program Diagram

SPI Config Code



  void csEnable(void)
  {
      HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_RESET);
  }

  void csDisable(void)
  {
      HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, GPIO_PIN_SET);
  }

  void spiWriteByte(uint8_t tx)
  {
      uint8_t rx;
      while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
      HAL_SPI_TransmitReceive(&hspi1, &tx, &rx, 1, 10);
      while (HAL_SPI_GetState(&hspi1) == HAL_SPI_STATE_BUSY_TX);    
  }

  uint8_t spiReadByte(void)
  {
      uint8_t rx = 0, tx = 0xFF;
      while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
      HAL_SPI_TransmitReceive(&hspi1, &tx, &rx, 1, 10);
      while (HAL_SPI_GetState(&hspi1) == HAL_SPI_STATE_BUSY_RX);
      return rx;
  }

  static void wizchip_read_burst(uint8_t *pBuf, uint16_t len)
  {
      HAL_SPI_Receive_DMA(&hspi1, pBuf, len);
      while (HAL_DMA_GetState(hspi1.hdmarx) == HAL_DMA_STATE_BUSY);
      while (HAL_SPI_GetState(&hspi1) == HAL_SPI_STATE_BUSY_RX);    
      return;
  }

  static void wizchip_write_burst(uint8_t *pBuf, uint16_t len)
  {
      HAL_SPI_Transmit_DMA(&hspi1, pBuf, len);
      while (HAL_DMA_GetState(hspi1.hdmatx) == HAL_DMA_STATE_BUSY);
      while (HAL_SPI_GetState(&hspi1) == HAL_SPI_STATE_BUSY_TX);
      return;
  }
  

Test Config

Test Config

Result

Program Log

SPI DMA config

AX2

SPI DMA config

WireShark

SPI DMA config

When transmitting 41,820 bytes using UDP, with a TX buffer allocated at 8K and an SPI clock at 20 MHz utilizing DMA, the results indicated that each transmission took approximately 25 to 35 milliseconds.

Documents

  • Nucleo_F412_W5100S_Test

    github source code

Comments

Similar projects you might like

Comments