Hi,
I am trying to read back the register i have written. But when i write the value in variable length or fixed length 1 byte mode, i am reading some thing else.
But It is proper for the both 2,4 fixed length modes.
Here is the code:
#include "Wizchip_Conf.h"
#include "W5500.h"
#include "Socket.h"
// ETH WIZ click connections
sbit Wizchip_Rst at LATE1_bit;
sbit Wizchip_CS at LATE0_bit;
sbit Wizchip_Rst_Direction at TRISE1_bit;
sbit Wizchip_CS_Direction at TRISE0_bit;
// end of ETH WIZ click connections
// brief Call back function for WIZCHIP select.
void CB_ChipSelect(void)
{
Wizchip_CS = 0;
}
// brief Call back function for WIZCHIP deselect.
void CB_ChipDeselect(void)
{
Wizchip_CS = 1;
}
uint8_t i;
uint8_t val[6];
void main(){
UART1_Init(9600);
Wizchip_Rst_Direction = 0;
Wizchip_CS_Direction = 0;
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
CB_ChipSelect();
SPI1_Write(0x00);
SPI1_Write(0x09);
SPI1_Write(0x04);
SPI1_Write(0x0A);
SPI1_Write(0x0B);
SPI1_Write(0x0C);
SPI1_Write(0x0D);
SPI1_Write(0x0F);
SPI1_Write(0x0E);
CB_ChipDeselect();
CB_ChipSelect();
SPI1_Write(0x00);
SPI1_Write(0x09);
SPI1_Write(0x00);
for(i =0; i<6; i++){
val[i] =SPI1_Read(0);
}
CB_ChipDeselect();
for(i = 0; i<6; i++){
UART1_Write(val[i]);
}
}
Here are my results when i use each of the mode:
1 Byte: 0xD5 0x05 0x00 0x00 0x00 0x00
2 Byte:0xAA 0x0B 0x00 0x00 0x00 0x87
4 Byte: 0xAA 0x0B 0x0C 0x0D 0x00 0x87
variable length mode: 0x55 0x05 0x0C 0x0D 0x00 0x00