---
title: "W5100 Arduino Shield on STM32L496AG Discovery Board"
url: "https://maker.wiznet.io/forum/12985"
markdown_url: "https://maker.wiznet.io/forum/12985/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "nyameen"
created: "2018-07-06T14:19:52+09:00"
last_activity: "2024-08-02T10:41:41+09:00"
language: "en"
views: 609
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5100 Arduino Shield on STM32L496AG Discovery Board

## Question

Asked by nyameen on 2018-07-06 in Ethernet Chips.

Hello,

Has anyone used the Arduino Ethernet shield with a W5100 on the STM32L496 board? I have tired to follow different example and the program gets hung on the wizchip_init(bufSize, bufSize); command. I believe it cannot initialize.

Also, if I am able to initialize it, can I use modbus TCP with the shield? Thank you.

> void wzn_select(void)
> {
> HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
> }
>
> void wzn_deselect(void)
> {
> HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
> }
>
> void wzn_write_byte(uint8_t wb)
> {
> HAL_SPI_Transmit(&hspi1, &wb, 1, 0xffff);
> }
>
> uint8_t wzn_read_byte(void)
> {
> uint8_t rd_byte = 0;
>
> HAL_SPI_Receive(&hspi1, &rd_byte, 1, 0xffff);
>
> return rd_byte;
> }
>
> void wzn_write(uint8_t* pBuf, uint16_t len)
> {
> HAL_SPI_Transmit(&hspi1, pBuf, len, 0xffff);
> }
>
> void wzn_read(uint8_t* pBuf, uint16_t len)
> {
> HAL_SPI_Receive(&hspi1, pBuf, len, 0xffff);
> }
>
> void wzn_config(void)
> {
> uint8_t bufSize = {2, 2, 2, 2};
>
> reg_wizchip_cs_cbfunc(wzn_select, wzn_deselect);
> reg_wizchip_spi_cbfunc(wzn_read_byte, wzn_write_byte);
>
> wizchip_init(bufSize, bufSize);
>
> wiz_NetInfo netInfo = { .mac = {0x00, 0x08, 0xdc,0x00, 0xab, 0xcd},
> .ip = {192, 168, 1, 64},
> .sn = {255, 255, 255, 0} };
>
> wizchip_setnetinfo(&netInfo);
> wizchip_getnetinfo(&netInfo);
>
> printf(“MAC Address: %02X:%02X:%02X:%02X:%02X:%02X\r\n”, netInfo.mac[0], netInfo.mac[1], netInfo.mac[2], netInfo.mac[3], netInfo.mac[4], netInfo.mac[5]);
> printf(“IP Address: %d.%d.%d.%d\r\n”, netInfo.ip[0],netInfo.ip[1],netInfo.ip[2],netInfo.ip[3]);
> printf(“SUB: %d.%d.%d.%d\r\n”, netInfo.sn[0],netInfo.sn[1],netInfo.sn[2],netInfo.sn[3]);
>
> }
>
> static void MX_GPIO_Init(void)
> {
> GPIO_InitTypeDef gpio;
>
> // SCK - PA5
> gpio.Pin = GPIO_PIN_5;
> gpio.Mode = GPIO_MODE_AF_PP;
> gpio.Pull = GPIO_PULLUP;
> gpio.Speed = GPIO_SPEED_HIGH;
> gpio.Alternate = GPIO_AF5_SPI1;
> HAL_GPIO_Init(GPIOA, &gpio);
>
> // MISO - PB4
> // MOSI - PB5
> gpio.Pin = GPIO_PIN_4 | GPIO_PIN_5;
> gpio.Mode = GPIO_MODE_AF_PP;
> gpio.Pull = GPIO_PULLUP;
> gpio.Speed = GPIO_SPEED_HIGH;
> gpio.Alternate = GPIO_AF5_SPI1;
> HAL_GPIO_Init(GPIOB, &gpio);
>
> // CS - PA15
> gpio.Pin = GPIO_PIN_15;
> gpio.Mode = GPIO_MODE_AF_PP;
> HAL_GPIO_Init(GPIOA, &gpio);
> }
>
> static void MX_SPI1_Init(void)
> {
> hspi1.Instance = SPI1;
> hspi1.Init.Mode = SPI_MODE_MASTER;
> hspi1.Init.Direction = SPI_DIRECTION_2LINES;
> hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
> hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
> hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
> hspi1.Init.NSS = SPI_NSS_SOFT;
> hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
> hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
> hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
> hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
> hspi1.Init.CRCPolynomial = 10;
> hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
> hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLED;
> HAL_SPI_Init(&hspi1);
> }

## Replies

### Reply 1 by Charlie Chen, 2024-08-02

Hi There, hope you fix it and I have same issue . Could you please share the reason. Thanks

---

Source: https://maker.wiznet.io/forum/12985
