W5500 Ethernet module with dsPIC30f
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 Ethernet module with dsPIC30f
by Eric-nguyen ·
Dear Vpan
Thank you for replying to me. I’m a new one in SPI protocol and when I’ve tried to make a new program, the conflict between w5500’s library and microchip’s library have occurred. With your advices, I think this problem is about the address, sorry for my slow on the uptake but can you explain more detail about it for me. I don’t know where I have to begin at…
This is my program and my build failed
// Socket & Port number definition
#define SOCK_ID_TCP 0
#define SOCK_ID_UDP 1
#define PORT_TCP 5000
#define PORT_UDP 10001
#define DATA_BUF_SIZE 1024
uint8_t gDATABUF[DATA_BUF_SIZE];
#define Wizchip_CS LATBbits.LATB2
#define Wizchip_CS_Direction TRISBbits.TRISB2
#define Wizchip_Rst LATBbits.LATB5
#define Wizchip_Rst_Direction TRISBbits.TRISB5
///////////////////////////////////////////////////////////////////////////////
volatile wiz_NetInfo gWIZNETINFO =
{
{0x00, 0x14, 0xA3, 0x72, 0x17, 0x3f}, // Source Mac Address
{192, 168, 0, 122}, // Source IP Address
{255, 255, 254, 0}, // Subnet Mask
{192, 168, 0, 1}, // Gateway IP Address
{192, 168, 14, 99}, // DNS server IP Address
NETINFO_STATIC
};
volatile wiz_PhyConf phyConf =
{
PHY_CONFBY_HW, // PHY_CONFBY_SW
PHY_MODE_MANUAL, // PHY_MODE_AUTONEGO
PHY_SPEED_10, // PHY_SPEED_100
PHY_DUPLEX_FULL, // PHY_DUPLEX_HALF
};
wiz_NetInfo pnetinfo;
////////////////////////////////////////////////////////////////////////////////
void InitSPI (void);
void CB_ChipSelect(void);
void CB_ChipDeselect(void);
void SPIWrite(unsigned int data);
unsigned int SPIRead();
void TCP_Server(void);
void UDP_Server(void);
static void W5500_Init(void);
void Delay_x_mS( int N_mS );
////////////////////////////////////////////////////////////////////////////////
void InitSPI (void){
unsigned int SPICONValue;
unsigned int SPISTATValue;
TRISFbits.TRISF6 =0; //Output RF6/SCK1
TRISFbits.TRISF2 =1; //Input RF2/SDI1
TRISFbits.TRISF3 =0; //Output RF3/SDO1
ADPCFGbits.PCFG2 =1; //Pin RB2 analog in
LATBbits.LATB2 = 1;
TRISBbits.TRISB2 = 0; // Output RB2 (CS RB2)
SPICONValue = FRAME_ENABLE_OFF& //FRMEN: 0= Framed SPI support disabled
FRAME_SYNC_OUTPUT& //SPIIFSD: 0= Frame sync pulse output(master)
ENABLE_SDO_PIN& //DISSDO: 0= SDOx pin is controlled by the module
SPI_MODE16_OFF& //MODE16: 0= Communication is byte-wide (8 bits)
SPI_SMP_OFF& //SMP: 0= Input data sample at middle of data output time
SPI_CKE_OFF& //CKE: 0= Serial output data changes on transition from Idle clk to active clk state
SLAVE_ENABLE_OFF& //SSEN: 0= SS pin not use by module. Pin controlled by port function
CLK_POL_ACTIVE_HIGH& //CKP: 1= Idle state for clock is high level. Active state is low level
MASTER_ENABLE_ON& //MSTEN: 1= Master mode
SEC_PRESCAL_3_1& //SPRE<2:0>: Secondary Prescale 3:1
PRI_PRESCAL_1_1; //PPRE<1:0>: Primary Presacle 1:1
SPISTATValue = SPI_ENABLE& //SPIEN: 1= Enables module and configures SCKx, SDOx, SDIx and SSx as serial port pin
SPI_IDLE_CON& //SPISIDL: 0= Continue module operation in Idle mode
SPI_RX_OVFLOW_CLR; //SPIROV: 0= No overflow has occurred. Clear receive overflow bit
}
// 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;
}
void SPIWrite(unsigned int data){
while(SPI1STATbits.SPITBF);
WriteSPI1(data);
}
// brief Callback function to read byte using SPI.
unsigned int SPIRead(){
uint8_t tmp = 0;
WriteSPI1(0);
while(!DataRdySPI1());
tmp = ReadSPI1();
return tmp;
}
// brief Handle TCP socket state.
void TCP_Server(void)
{
int32_t ret;
uint16_t size = 0, sentsize = 0;
}
// brief Handle UDP socket state.
void UDP_Server(void)
{
int32_t ret;
uint16_t size, sentsize;
uint8_t destip[4];
uint16_t destport;
}
// brief Initialize modules
static void W5500_Init(void)
{
// Set Tx and Rx buffer size to 2KB
uint8_t buffsize[8] = { 2, 2, 2, 2, 2, 2, 2, 2 };
// SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
}
void Delay_x_mS( int N_mS )
{
int Loop_mS,Del_1mS;
}
////////////////////////////////////////////////////////////////////////////////
int main(void)
{
ADPCFG = 0; // Set PORT B as digital
InitSPI();
W5500_Init();
wizchip_getnetinfo(&pnetinfo);
}