- Fri May 17, 2013 11:04 pm
#159535
Hello all,
I'm attempting to control the Wiznet W5100 module using the LPC2138 SSP controller. I've read up on SSP usage and the Wiznet SPI command structure, and the following code SHOULD set p to 0x0F (for further testing). However, every read on SSPDR returns 0x00. I've posted code and a schematic to help determine why SSPDR reads 0x00, whether it be improper SSP usage or trouble with the Wiznet module (I suspect the latter).
Schematic: https://dl.dropboxusercontent.com/u/131 ... ematic.png
I'm attempting to control the Wiznet W5100 module using the LPC2138 SSP controller. I've read up on SSP usage and the Wiznet SPI command structure, and the following code SHOULD set p to 0x0F (for further testing). However, every read on SSPDR returns 0x00. I've posted code and a schematic to help determine why SSPDR reads 0x00, whether it be improper SSP usage or trouble with the Wiznet module (I suspect the latter).
Schematic: https://dl.dropboxusercontent.com/u/131 ... ematic.png
Code: Select all
//SPI1/SSP initialization ~~~~~~~~~~~~~~~~~~~~~~~~
//initialize p0.20(SSEL) as GPIO output, idle high
IO0DIR |= 0x00100000;
IO0SET = 0x00100000;
//connect p0.17-19 to SSP controller, p0.20 to GPIO
PINSEL1= ((PINSEL1 & ~0x000003FC) | 0x000000A8);
//8-bit SPI w/ PCLK / 2
SSPCPSR= 0x00000002;
SSPCR0= 0x00000007;
//enable SPI
SSPCR1= 0x00000002;
//end SPI1/SSP initialization ~~~~~~~~~~~~~~~~~~~~
IO0DIR |= LEDPIN;
IO0CLR= 0x00100000;
SSPDR= 0xF0;
SSPDR= 0x00;
SSPDR= 0x00;
SSPDR= 0x01;
while(SSPSR & BSY);
IO0SET= 0x00100000;
for(i= 0; i < 4; i++) q[i]= SSPDR;
p= (q[0] == 0x00) ? 8 : 0;
p += (q[1] == 0x01) ? 4 : 0;
p += (q[2] == 0x02) ? 2 : 0;
p += (q[3] == 0x03) ? 1 : 0;