Content originally posted in LPCWare by timer on Thu Jan 26 16:36:24 MST 2012 Hello,
I try to read with SSI (SSP) from an Sensor. With my Oszi I can see the data is comming but I dont find all the 16bits.
Actually I this routine with Length = 1 because the I get one clock-"burst" with 16 periodes.
void SSP1Receive(uint8_t *buf, uint32_t Length )
{
uint32_t i;
for (i=0; i<Length; i++)
{
// send a dummy byte, read the result
LPC_SSP1->DR = 0xFF; // send 0xFF as dummy
/* Wait until the Busy bit is cleared */
while ( (LPC_SSP1->SR & (SSPSR_BSY|SSPSR_RNE)) != SSPSR_RNE );
*buf++ = LPC_SSP1->DR;
}
return;
}
This Code is form the SSP-Example but I get as you may expect only one 8bit value in the buffer. But I need 16bit. I try to change the *buf to a uin16_t because I think I have to use the whole accessable DR-Register, but come into the "HardFault_Handler" and had to reset.
Does anybody know how I can get the whole 16bits data?
Content originally posted in LPCWare by timer on Fri Jan 27 09:55:39 MST 2012 I found a way that it works. Now I use 3 times 6-bit and get all my needed bits out of them.
Content originally posted in LPCWare by Ex-Zero on Fri Jan 27 00:32:17 MST 2012 I'm not sure what your sensor is expecting
Of course chip select is always an issue, but if you switch off SSEL function and use CS via GPIO it could be possible that 2*8bit is working. Otherwise you have to extend your SSP receive function to receive 16 bit :eek:
If your data register (LPC_SSP1->DR) is already able to receive correct 16 bit data you could also store them as 2 bytes in your byte buffer with something like: