CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SHT40-AD1B temperature and Humidity sensor issue
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
andrew007



Joined: 27 Feb 2023
Posts: 8

View user's profile Send private message

PostPosted: Tue Mar 07, 2023 9:05 am     Reply with quote

Ttelmah wrote:
I think what was peculiar, was the decision when designing I2C, to put the
R/W bit at the bottom of the address field. It could have been put at the
top just as easily, and if so the addresses wouldn't have the issue of having
to be doubled when used in the byte...

it would have been better, actually Smile
Gordon23



Joined: 17 Feb 2024
Posts: 6
Location: UK

View user's profile Send private message

I2C 7 Bits - Direction
PostPosted: Thu Feb 29, 2024 2:26 am     Reply with quote

Hi,

I know this is an old topic, but i came across it, and was a bit confused.

The device in quetion has a 7 bit address followed by a direction bit.

I understand that the PIC uses 8 bits and in order to talk to the device the address needs to be shifted.

But - in the code suggested:-

#define SHT40_BASE_ADDR 0x88
#define SHT4X_CMD_MEASURE_HPM 0xFD

//================================
void main(void)
{
unsigned int8 wData[1] = SHT4X_CMD_MEASURE_HPM;
unsigned int8 rData[6] = {0};

ack = i2c_transfer_out(SHT40_BASE_ADDR, wData, 1);
.
.
.

ack=i2c_transfer_in(SHT40_BASE_ADDR, rData, 6);
.
.
.

while(TRUE)
{
//TODO: User Code
}
}




How would the device know if it is a read or write? The address being sent for transfer in/out is the same?

Can someone explain for me?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Thu Feb 29, 2024 2:52 am     Reply with quote

It's hidden from you when using i2C_transfer.
In these commands the read bit is automatically set for address for the
restart the 'in' command.
Normally (if you use the manual commands instead), you have to set the
read bit for a read command yourself.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group