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

daventech TPA81 HELP!!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
macgyver



Joined: 24 Aug 2005
Posts: 12

View user's profile Send private message

daventech TPA81 HELP!!!
PostPosted: Thu Jul 06, 2006 2:00 pm     Reply with quote

anyone use this unit here is teh cde i am trying to use but cant seem to get it to work. not sure if i am reading it right, any help would be greatly appreicated.

specs of it
http://www.robot-electronics.co.uk/htm/tpa81tech.htm



#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#use i2c(Master, SDA=PIN_C4, SCL=PIN_C3, FORCE_HW)

int8 a1,a2,a3;

void get_temp()
{
i2c_start();
i2c_write(0xD0);
delay_ms(50);
a1 = i2c_read();
a2 = i2c_read();
a3 = i2c_read();
a4 = i2c_read(0);
i2c_stop();
}


void main()
{


while(1)
{

void get_temp();


printf("temp1 = %u\n\r", a1);
printf("temp2 = %u\n\r", a2);
printf("temp3 = %u\n\r", a3);
delay_ms(500);
}

}
macgyver



Joined: 24 Aug 2005
Posts: 12

View user's profile Send private message

also
PostPosted: Thu Jul 06, 2006 2:03 pm     Reply with quote

tried

printf("temp1 = %2X\n\r", a1);
printf("temp2 = %2X\n\r", a2);
printf("temp3 = %2X\n\r", a3);

but all i get is FF
epideath



Joined: 07 Jun 2006
Posts: 47

View user's profile Send private message

PostPosted: Thu Jul 06, 2006 4:08 pm     Reply with quote

Do you have the pull-up resistors attached to the SDA and SCL lines?

You need to read the tutorial under the Connections on the link you had above. It seems that you are missing quite a bit. You need to do a start then send the address and the register you wish to read. Then send another start bit with the address set with the read bit set. so in your case it would be 0xD1 instead of 0xD0. Then you can read the value in the register.

I have never used this unit before so I'm no expert. Just from what I got from reading through it.

Regards
Guest








pullup
PostPosted: Thu Jul 06, 2006 4:46 pm     Reply with quote

yep got it done, i think i am missing something in the i2c sequence, thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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