W5500 SPI 통신을 이용한 TCP/IP 통신 에러
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: W5500 SPI 통신을 이용한 TCP/IP 통신 에러
by bruno WIZnet ·
환경
PC -----(TCP/IP)----- W5500 -----(SPI)----- 임베디드 장비
정상동작
PC ----->(TCP/IP)-----> W5500 ----->(SPI)-----> 임베디드 장비
비정상 동작(1회만 성공)
PC <-----(TCP/IP)<----- W5500 <-----(SPI)<----- 임베디드 장비
어느 부분에서 문제가 생겼는지(화살표 구간별) 디버깅이 필요합니다.
RE: W5500 SPI 통신을 이용한 TCP/IP 통신 에러
by Chobo Song ·
임베디드 장비의 socket.c 파일에 있는 send( ) 함수에서 에러?가 발생하네요.
int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
{
uint8_t tmp=0;
uint16_t freesize=0;
CHECK_SOCKNUM();
CHECK_SOCKMODE(Sn_MR_TCP);
CHECK_SOCKDATA();
tmp = getSn_SR(sn);
if(tmp != SOCK_ESTABLISHED && tmp != SOCK_CLOSE_WAIT) return SOCKERR_SOCKSTATUS;
if( sock_is_sending & (1<<sn) )
{
tmp = getSn_IR(sn);
if(tmp & Sn_IR_SENDOK)
{
setSn_IR(sn, Sn_IR_SENDOK);
//M20150401 : Typing Error
//#if WZICHIP == 5200
#if WIZCHIP == 5200
if(getSn_TX_RD(sn) != sock_next_rd[sn])
{
setSn_CR(sn,Sn_CR_SEND);
while(getSn_CR(sn));
return SOCK_BUSY;
}
#endif
sock_is_sending &= ~(1<<sn);
}
else if(tmp & Sn_IR_TIMEOUT)
{
close(sn);
return SOCKERR_TIMEOUT;
}
else return SOCK_BUSY;
}
freesize = getSn_TxMAX(sn);
if (len > freesize) len = freesize; // check size not to exceed MAX size.
while(1)
{
freesize = getSn_TX_FSR(sn);
tmp = getSn_SR(sn);
if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT))
{
close(sn);
return SOCKERR_SOCKSTATUS;
}
if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
if(len <= freesize) break;
}
wiz_send_data(sn, buf, len);
#if WIZCHIP == 5200
sock_next_rd[sn] = getSn_TX_RD(sn) + len;
#endif
#if WIZCHIP == 5300
setSn_TX_WRSR(sn,len);
#endif
setSn_CR(sn,Sn_CR_SEND);
/* wait to process the command… */
while(getSn_CR(sn));
sock_is_sending |= (1 << sn);
//M20150409 : Explicit Type Casting
//return len;
return (int32_t)len;
}
첫 packet을 전송한 후에 다음 send를 수행하는 경우 위에 Bold로 표시된 부분인 SOCK_BUSY값이 반환됩니다.
이런경우 어떤 부분을 살펴봐야 할까요?
RE: RE: W5500 SPI 통신을 이용한 TCP/IP 통신 에러
by Chobo Song ·
send 후에 sock_is_sending 에 설정된 bit를 Clear하지 않아서 발생하는 문제입니다.
send 후 인터럽트 처리루틴에서 Sn_IR_SENDOK 가 발생하면 socket.c 파일에 static으로 선언된 sock_is_sending 변수의 해당 flag를 clear해주면 다음 전송이 정상적으로 이루어 지기는 합니다.
인터럽트와 send 함수사이에 sock_is_sending 처리부분을 좀더 살펴보면 해결이될것 같습니다.
감사합니다.