W5100 SPI Packet Format Error
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: W5100 SPI Packet Format Error
by hjjeon0608 ·
Hi,
I don’t understand your question.
What is the wrong format??
When you read the TX write pointer, the value is 0x0000.
RE: W5100 SPI Packet Format Error
by ashes ·
Hi, i think the photo is confusing i put it because the packet format error is clear to see in that (response: 0x03 0xFF 0xFF 0xFF). I often see the packet format error when i read Tx_WR or RD pointer. So the chip go crazy because that looks 0xFF (my IINCHIP_Read implementation return last byte of packet)and when i send the data with send function the chip bombing TCP line via sending multiple 1460 bytes packages (i send 4 byte only.).
RE: W5100 SPI Packet Format Error
by hjjeon0608 ·
You mean that when 0x001A(RMSR) is written, MISO responses is 0x03 0xFF 0xFF 0xFF ???
When MCU writes to W5100, you should ignore response.
The value is nothing.
You just care about last byte 0x01. It is written data.
RE: W5100 SPI Packet Format Error
by ashes ·
[quote=“hjjeon0608”]You mean that when 0x001A(RMSR) is written, MISO responses is 0x03 0xFF 0xFF 0xFF ???
When MCU writes to W5100, you should ignore response.
The value is nothing.
You just care about last byte 0x01. It is written data.[/quote]
Okay, we can ignore writing’s sequence response.
My problem is when i read Tx_WR and Tx_RD pointer values the spi package error happens occasionally. So send function manage Tx pointer in a wrong way after that i see multiple 1460 byte data packages on wireshark and my tcp test tool even if i send 4 bytes data package.
I will post some pictures about it at the end of the day.
RE: W5100 SPI Packet Format Error
by ashes ·
You can see TX_Wr read error in first picture
When i read 0x0424 it’s perfectly normal.
Second picture’s code piece :
[code]
sysinit(0x55, 0x55);
close(0);
if(socket(0,Sn_MR_TCP,32100,0x00) == 0)
return;
listen(0) ;
/You can see all data flow in second picture of these debug areas/
debug = IINCHIP_READ(Sn_TX_WR0(0));
debug = IINCHIP_READ(Sn_TX_WR0(0) + 1);
debug = IINCHIP_READ(Sn_TX_RD0(0));
debug = IINCHIP_READ(Sn_TX_RD0(0) + 1);[/code]
RE: W5100 SPI Packet Format Error
by hjjeon0608 ·
Plz, post your send function and iinchip_read, iinchip_write.
RE: W5100 SPI Packet Format Error
by ashes ·
send function is library’s function i used as is .
[code]uint16 send(
SOCKET s, /< the socket index */
const uint8 * buf, /< a pointer to data */
uint16 len /**< the data size to be send */
)
{
uint8 status=0;
uint16 ret=0;
uint16 freesize=0;
#ifdef DEF_IINCHIP_DBG
printf(“send()\r\n”);
#endif
ret = getIINCHIP_TxMAX(s);
if (len > getIINCHIP_TxMAX(s))
ret = getIINCHIP_TxMAX(s); // check size not to exceed MAX size.
else
ret = len;
// if freebuf is available, start.
do
{
freesize = getSn_TX_FSR(s);
status = IINCHIP_READ(Sn_SR(s));
if ((status != SOCK_ESTABLISHED) && (status != SOCK_CLOSE_WAIT))
{
ret = 0;
break;
}
#ifdef DEF_IINCHIP_DBG
printf(“socket %d freesize(%d) empty or error\r\n”, s, freesize);
#endif
} while (freesize < ret);
send_data_processing(s, (uint8 *)buf, ret);
IINCHIP_WRITE(Sn_CR(s),Sn_CR_SEND);
/* +20071122[chungs]:wait to process the command… /
while( IINCHIP_READ(Sn_CR(s)) )
;
/ ------- */
/* +2008.01 bj /
//#ifdef DEF_IINCHIP_INT
// while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK )
//#else
while ( (IINCHIP_READ(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK )
//#endif
{
/ m2008.01 [bj] : reduce code /
if ( IINCHIP_READ(Sn_SR(s)) == SOCK_CLOSED )
{
#ifdef DEF_IINCHIP_DBG
printf(“SOCK_CLOSED.\r\n”);
#endif
close(s);
return 0;
}
}
/ +2008.01 bj */
#ifdef DEF_IINCHIP_INT
putISR(s, getISR(s) & (~Sn_IR_SEND_OK));
#else
IINCHIP_WRITE(Sn_IR(s), Sn_IR_SEND_OK);
#endif
return ret;
}[/code]
IINCHIP read and write functions. In w5100.c I use like this : return user_IINCHIP_READ(…) and return user_IINCHIP_WRITE(…)
RE: W5100 SPI Packet Format Error
by ashes ·
I add retransmission property in IINCHIP_Read function but the things get worst. Once the communication is blown up, the chip never returns a valid packet.
My modifications:
1-) If the data package is not valid which is
first byte not equal 0x00,
second byte not equal 0x01,
third byte not equal 0x02
if any of these conditions happen, i read MR (address 0x0000) register. Here is the logic analyzer log
RE: W5100 SPI Packet Format Error
by hjjeon0608 ·
Hi,
I read your question through.
And I have some question.
What value you write to Tx wr pointer register??
Can you read the same value that you write?? I cannot see write value. So I cannot judge what is wrong value.
You read Tx rd pointer and then add length of data you want to send and then write to the tx wr pointer???
When you read Tx wr pointer register or Tx rd pointer register several times, the value are different??
RE: W5100 SPI Packet Format Error
by ashes ·
[quote=“hjjeon0608”]Hi,
I read your question through.
And I have some question.
What value you write to Tx wr pointer register??
Can you read the same value that you write?? I cannot see write value. So I cannot judge what is wrong value.
You read Tx rd pointer and then add length of data you want to send and then write to the tx wr pointer???
When you read Tx wr pointer register or Tx rd pointer register several times, the value are different??[/quote]
1-)I think the attachment will answer your question(at right side of photo you see the retransmission mechanism is worked and get the right value of S0_TX_WR but it works 1-2 times after that it can’t help anymore to us)
2-) This question’s answer is in wiznet library, i modify only IINCHIP_Read function with retransmission. (Here is the link:
wiznet.co.kr/Admin_Root/UpLo … _DV_V180(0.zip)
3-)When I can read a valid spi package from w5100, there is no problem with tx_wr, tx_rd pointer values. But the library gets the broken pointer value(by broken spi package) add my data length to tx_wr pointer and boom whole communication is blown up because the pointer value has been damaged because of non-valid spi package. But as i said if the packages are solid, pointer values are solid.