Content originally posted in LPCWare by micro9000 on Thu Aug 22 14:53:41 MST 2013
I managed to figure it out. I needed a delay after and before the /CS pin was asserted low and high. Here is what the read statement look like within the main while loop now:
else
{
systick_delay(1); // wait 1ms
PORT_CS->FIOCLR |= PIN_MASK_CS;//CS low
SSP_SendData(SSP_CHANNEL,READ); // read command
SSP_SendData(SSP_CHANNEL,0x00); // byte 1 16bit address to read
SSP_SendData(SSP_CHANNEL,0x00); // byte 2 16bit address to read
SSP_SendData(SSP_CHANNEL,0x00); // clock data out for reading
readSPIvalue=SSP_ReceiveData(SSP_CHANNEL);
systick_delay(1); // 1ms
PORT_CS->FIOSET |= PIN_MASK_CS; //CS High
}
I have to find out how to use timers as delays, for milliseconds using system tick isn't going to cut it. From the datasheet, the delay has to be about 100ns, but it still works with 1ms. I think I can use the match register to do this I just have to configure the PCLK to be system clock divided by 2 instead of 4.