Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

LuSa_1231216
Level 2
Level 2
First like received First solution authored 10 sign-ins

// I2C BUSSCAN  - SCAN CONNECTED SENSORS
void I2C_BUSSCAN(void ){
BYTE bAddress,bStatus;
SensorPresent=0;


for (i=0; i<3; i++){
switch (i){
case 0: bAddress=0x40; //ADDRESS HDC1080
break;
case 1: bAddress=0x5A; // ADDRESS CSS811
break;
case 2: bAddress=0xE0; // ADDRESS SRF02
}

I2CHW_fSendStart(bAddress,I2CHW_READ);
I2CHW_SendStop();
bStatus=I2CHW_bReadI2CStatus() & I2CHW_RD_COMPLETE;
I2CHW_ClrRdStatus();

Delay50uTimes(20);
if (bStatus==0 & bAddress==0x40)HDC1080=1;else HDC1080=0; // HDC1080
if (bStatus==0 & bAddress==0x5A)CSS811=2;else CSS811=0; // CSS811
if (bStatus==0 & bAddress==0xE0)SRF02=4;else SRF02=0; // SRF02

}

 

0 Likes
1 Solution
LuSa_1231216
Level 2
Level 2
First like received First solution authored 10 sign-ins

The suggestion whit the  LRB Bit Works ...

// I2C BUSSCAN SCAN FOR CONNECTED SENSORS
void I2C_BUSSCAN(void ){
BYTE bStatus;
for (i=0; i<3; i++){
switch (i){
case 0: I2CHW_fSendStart(0x40,I2CHW_READ); //ADDRESS HDC1080
if(I2CHW_SCR & 0x02)HDC1080=0; else HDC1080=1;

break;
case 1: I2CHW_fSendStart(0x5A,I2CHW_READ); //ADDRESS CSS811
if(I2CHW_SCR & 0x02)CSS811=0;else CSS811=2;

break;
case 2: I2CHW_fSendStart(0xE0,I2CHW_READ); //ADDRESS SRF02
if(I2CHW_SCR & 0x02)SRF02=0;else SRF02=4;

}
I2CHW_SendStop();
}

SensorPresent=bRegLo[45]=HDC1080|CSS811|SRF02;
}

View solution in original post

2 Replies
MotooTanaka
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Hi,

Although I don't have access to PSoC1,
I would check the I2C Status before I2CHW_SendStop().

We can (or should be able to) check if the slave returned ACK to  SendStart().

But most likely the condition will be cleared if you send stop.

moto

0 Likes
LuSa_1231216
Level 2
Level 2
First like received First solution authored 10 sign-ins

The suggestion whit the  LRB Bit Works ...

// I2C BUSSCAN SCAN FOR CONNECTED SENSORS
void I2C_BUSSCAN(void ){
BYTE bStatus;
for (i=0; i<3; i++){
switch (i){
case 0: I2CHW_fSendStart(0x40,I2CHW_READ); //ADDRESS HDC1080
if(I2CHW_SCR & 0x02)HDC1080=0; else HDC1080=1;

break;
case 1: I2CHW_fSendStart(0x5A,I2CHW_READ); //ADDRESS CSS811
if(I2CHW_SCR & 0x02)CSS811=0;else CSS811=2;

break;
case 2: I2CHW_fSendStart(0xE0,I2CHW_READ); //ADDRESS SRF02
if(I2CHW_SCR & 0x02)SRF02=0;else SRF02=4;

}
I2CHW_SendStop();
}

SensorPresent=bRegLo[45]=HDC1080|CSS811|SRF02;
}