---
title: "[W5500] 통신 테스트"
url: "https://maker.wiznet.io/forum/12549"
markdown_url: "https://maker.wiznet.io/forum/12549/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "bklim3271"
created: "2017-11-03T09:52:04+09:00"
last_activity: "2017-11-07T01:38:40+09:00"
language: "ko"
views: 1029
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# [W5500] 통신 테스트

## Question

Asked by bklim3271 on 2017-11-03 in Ethernet Chips.

ATMEGA128을 이용하여 WIZ550IO porting 중에 있습니다.
통신속도는 8Mhz이며 기본적인 setting(SPI / VDM사용)을 구현하였습니다.
통신 확인을 위해서 getRCR()를 이용하여 전송시 0x03 값이 feedback이 들어오는걸 확인하였습니다. 다른 파라미터를 보내봐도 동일하게 0x03으로 feedback이 수신되고 있습니다.
check point를 문의드립니다.

하드웨어 구성이랑 코드 아래와 같이 작성하였습니다.
더 필요한 정보있으시면 말씀해주세요~

1. 하드웨어 구성
   Master(atmel) Wiz550io
   PB1(SCK)_out ---------------> J1_Pin5(SCK)
   PB2(MOSI)_out ---------------> J1_Pin3(MOSI)
   PB3(MISO)_in &lt;--------------- J1_Pin4(MISO)
   PB4(SS control)_out ----------> J1_Pin6(SCSn)

2. 코드

```
#define SS_1 PORTB |= 0x10; // PORTB or 0x10 => Low -> high
#define SS_0 PORTB &= ~ 0x10; // PORTB or 0x10 => High -> Low
int main(void)
{
SPI_Masterinit();
USART_init();
reg_wizchip_cs_cbfunc(wizchip_select, wizchip_deselect);				
reg_wizchip_spi_cbfunc(wizchip_read, wizchip_write);

if(getRCR() != 0x08)
{ 
	unsigned int j = 0;
	j = getRCR();
	putchar0(j);	// 순서대로 보내기
}
}
void wizchip_select(void)
{
SS_0;
}
void wizchip_deselect(void)
{
SS_1;
}
void wizchip_write(uint8_t wb)
{
unsigned char data;
data = wb;
SPCR&=~0x80;
SPDR=data;
while(!(SPSR&0x80));
SPCR|=0x80;
}
uint8_t wizchip_read()
{
unsigned char data;
while(!(SPSR&0x80));
data = SPDR;
SPCR|=0x80;
return data;
}
```

## Replies

### Reply 1 by bangbh, 2017-11-07

wizchip_read() 함수에서 SPDR에 더미 데이터를 넣는 부분을 깜박하신게 아닐까요?

wizchip_read() 함수 처음에 아래 코드를 삽입하시면 정상동작할 것 같습니다.

SPDR = data;

수고하세요.

---

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