I'm working with a proc 4 device and a LIS3DH accelerometer. I've stripped down my code to do the most basic thing to demonstrate my problem. I read the "who am I" register (0x0F) of the accelerometer. The response is 0x33 and that's just what I get if I let the psoc read it once, twice or even 10 times. But if I read it (or other registers more than ten times the proc hangs. I'm watching everything on the I2C bus with a logic analyzer. I can tell it hangs because it doesn't get to the LED section at the end.
Thanks for any help with this...
Kevin
#include <project.h>
uint32 i;
uint8 userArray[6] = {0x01,0x02,0x03,0x04,0x05,0x06};
uint8 status;
uint8 I2C_WRITE_XFER_MODE = 0x00u;
uint8 I2C_I2CMSTR_NO_ERROR;
uint32 LIS3DH_ADDRESS = 0x18 ;
int main()
{ CyGlobalIntEnable;
LED_Green_Write(0);
// UART_Start();
// UART_UartPutString("The first words out...");
I2C_Start(); //Start the I2C component
I2C_I2CMasterSendStart(LIS3DH_ADDRESS, I2C_I2C_WRITE_XFER_MODE);
// I2C_I2CMasterWriteByte(0x20);
// I2C_I2CMasterWriteByte(0x97);
// I2C_I2CMasterSendStop();
for(i=0; i<10; i++)
{
I2C_I2CMasterSendStart(LIS3DH_ADDRESS, I2C_I2C_WRITE_XFER_MODE);
I2C_I2CMasterWriteByte(0x0F);
I2C_I2CMasterSendStop();
I2C_I2CMasterSendStart(LIS3DH_ADDRESS, I2C_I2C_READ_XFER_MODE);
userArray[i] = I2C_I2CMasterReadByte(I2C_I2C_ACK_DATA);
I2C_I2CMasterSendStop();
}
LED_Blue_Write(0);
LED_Green_Write(1);
I2C_I2CMasterSendStop(); /* Send Stop */
}
/* [] END OF FILE */