Using GPIO for SPI CS

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Dubbie on Sat Jul 05 18:48:00 MST 2014

I am working with a chip that sends up to 32bit ints

I have managed to talk to it using 16bit frames like the datasheet shows. However, the datasheet specifies that the CS must be held low while the instruction to retrieve the CNTR register is issued (an 8bit intstruction) and then kept low while the rest of the bits come in.

I get the first 8 bits because they come immediately after the read instruction is sent, but as soon as the CS goes high, the chip stops sending data. Even though I send zeros immediately after, no more data arrives.

It seems to me that I need to use a GPIO pin to "roll my own" CS line. My question is, I have no idea how to time this. Any suggestions are very welcome.

This is the datasheet. Page 8 shows the relevant diagram

I have also attached a screenshot from my scope for a read operation.

Here is my code I am using to read the register

uint16_t ntx_data;
ntx_data = (0x6000); // instruction read the CNTR register 0110 0000 0000 0000
Chip_SSP_SendFrame(LPC_SSP, ntx_data);
ntx_data = (0x0000); // send nothing to keep the clock going
Chip_SSP_SendFrame(LPC_SSP, ntx_data);

uint16_t rxedData = Chip_SSP_ReceiveFrame(LPC_SSP); // get first frame
uint16_t rxedData2 = Chip_SSP_ReceiveFrame(LPC_SSP); // get second frame

I am using LPCOpen with LPCXpresso on an LPC1347Xpresso dev board