- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello together,
i have an SDP601 Sensor http://www.mouser.com/ds/2/682/Sensirion_Differential_Pressure_SDP6x0series_Datas-767275.pdf
The Sensor uses I2C to communicate. I have connected the Sensor to a PSOC 5LP Development Board but it doesn't work.
#include <project.h>
#define I2C_SLAVE_ADDRESS (0x40)
uint8 temp;
uint8 status;
uint8 Sensor_Command = 0xF1; // Command for Sensor
uint8 Sensor[3];
uint8 i= 0;
uint8 j= 0;
int main()
{
CyGlobalIntEnable; /* Enable global interrupts. */
LCD_Start();
I2C_Start();
status = I2C_MasterSendStart(0x40, I2C_WRITE_XFER_MODE);
if(I2C_MSTR_NO_ERROR == status) /* Check if transfer completed without errors */
{
status = I2C_MasterWriteByte(Sensor_Command);
}
status = I2C_MasterSendStart(0x40, I2C_READ_XFER_MODE);
Sensor[0] = I2C_MasterReadByte(I2C_ACK_DATA);
status = I2C_MasterStatus();
Sensor[1] = I2C_MasterReadByte(I2C_ACK_DATA);
status = I2C_MasterStatus();
Sensor[2] = I2C_MasterReadByte(I2C_ACK_DATA);
status = I2C_MasterStatus();
I2C_MasterSendStop(); /* Send Stop */
LCD_PrintInt8(Sensor[0]);
LCD_PrintInt8(Sensor[1]);
LCD_PrintInt8(Sensor[2]);
while(1)
{
}
}
I tried many other code but it will not work. What can I do? Can you write working example Code?
SCL is connected to P0[0] SDA is connected to P0[1]
The LCD is connected to P2[0]-P2[6]
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you put the pull up resistors on the I2C lines? Please post your complete code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes i have 2 pull up resistors to VDD
This is the whole testing code..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to check the other parts of the program like the topdesign.cysch and other things that may cause issues. Please Press File and then select Create WorkSpace Bundle and attach to a Comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Sensor Array puts F10000 on the LCD. I dont know why its showing the command header of the sensor als Measuring value xD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes but the PSOC Function wants the adress und sets the 1 for read to the LSB that should be 81?
I tried everything but it didnt work. What can i do?
Can someone write the code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The high-level APIs usually are used in this way:
Writing to slave Count bytes
I2C_MasterWriteBuf(SlaveAddress,DataPtr,Count,I2C_MODE_COMPLETE_XFER);
Reading from Slave sending register/command byte first:
I2C_MasterWriteBuf(SlaveAddress,&RegAddress,1,I2C_MODE_NO_STOP);
I2C_MasterReadBuf(SlaveAddress,DataPtr,Count,I2C_MODE_REPEAT_START);
It is easier for us to help when you post your complete project so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, you didn't. You use I2C_MODE_COMPLETE_XFER instead of I2C_MODE_NO_STOP
Keep in mind that most of the APIs (except those for reading a byte) return a status byte which, when non-zero indicate an error condition.
You should check for that and find the reason (listed in I2C.h)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I2C_MasterWriteBuf(0x40, &mybyte, 1, I2C_MODE_NO_STOP); returns 0x00 and looks fine
I2C_MasterReadBuf(0x40, Sensor, 1, I2C_MODE_REPEAT_START); returns 0x02 and looks like an error. But i dont know why