[From QnA]I can't read or write registers via SPI
IO Modules
No replies yet. Be the first to reply.
Join the discussion.
IO Modules
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: [From QnA]I can't read or write registers via SPI
by wiznetmuseum ·
Dear Sir,
For the SPI control, SPI_EN pin is asserted High and /SCS pin starts with Low and ends with High. Please refer to below code.
===============================================================
/**
@brief This function writes the data into W5100 registers.
*/
uint8 IINCHIP_WRITE(uint16 addr,uint8 data)
{
IINCHIP_ISR_DISABLE();
IINCHIP_SpiInit();
//SPI MODE I/F
IINCHIP_CSoff(); // SCS=0, SPI start
IINCHIP_SpiSendData(0xF0); //Write OP code
IINCHIP_SpiSendData((addr & 0xFF00) >> 8); //High Address
IINCHIP_SpiSendData(addr & 0x00FF); //Low Address
IINCHIP_SpiSendData(data); //Write Data
IINCHIP_CSon(); // SCS=1, SPI end
IINCHIP_ISR_ENABLE();
return 1;
}
/**
@brief This function reads the value from W5100 registers.
*/
uint8 IINCHIP_READ(uint16 addr)
{
uint8 data;
IINCHIP_ISR_ENABLE();
IINCHIP_ISR_DISABLE();
IINCHIP_SpiInit();
IINCHIP_CSoff(); // SCS=0, SPI start
IINCHIP_SpiSendData(0x0F); //Read OP code
IINCHIP_SpiSendData((addr & 0xFF00) >> 8); //High Address
IINCHIP_SpiSendData(addr & 0x00FF); //Low Address
IINCHIP_SpiSendData(0);
data = IINCHIP_SpiRecvData(); //Read Data
IINCHIP_CSon(); // SCS=1, SPI end
IINCHIP_ISR_ENABLE();
return data;
}