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 CCS Technical Support

SRF08 with 16F877A using I2C not working

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



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

SRF08 with 16F877A using I2C not working
PostPosted: Tue Mar 14, 2006 1:08 pm     Reply with quote

Just wondering if anyone has any experience with the SRF08 sonar unit from Acroname. I've got 5 volts going to the unit and a small LED tells me I've got the I2C address correct.

The I2C address of the unit is 0xE0, the unit specification to go in that address for inches is 0x50 and 17 separate echos from one ping can be read from 0x02 to 0x23.

When I read the first four locations I just get an "ff".

Here is my code:
Code:
#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#use i2c(Master,sda=PIN_B1,scl=PIN_B0)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

main()
{
int i;
int echo_reading[4];
port_b_pullups(TRUE);
while(1)
 {
  i2c_start();
  i2c_write(0xE0);
  i2c_write(0x50);
  delay_ms(66);
  echo_reading[0]=i2c_read(0x02);
  echo_reading[1]=i2c_read(0x03);
  echo_reading[2]=i2c_read(0x04);
  echo_reading[3]=i2c_read(0x05);
  printf("one = %x two= %x three = %x four= %x",echo_reading[0],echo_reading[1],echo_reading[2],echo_reading[3]);
 
 }
}


Thanks, Harry
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