|
|
View previous topic :: View next topic |
Author |
Message |
macgyver
Joined: 24 Aug 2005 Posts: 12
|
daventech TPA81 HELP!!! |
Posted: Thu Jul 06, 2006 2:00 pm |
|
|
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
|
also |
Posted: Thu Jul 06, 2006 2:03 pm |
|
|
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
|
|
Posted: Thu Jul 06, 2006 4:08 pm |
|
|
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 |
Posted: Thu Jul 06, 2006 4:46 pm |
|
|
yep got it done, i think i am missing something in the i2c sequence, thanks |
|
|
|
|
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
|