SRF08 Problems - Only one long flash at startup, is this a common problem?

Hi, I'm having problems interfacing with a SRF08 via a HCS12. When you connect it its ment to flash out its IIC address. I.e. one long pulse then flash out the address. Firstly mine just does one long pulse, secondly how do you work out the address from a bunch of flashes? Do you have to time them, like 1 sec no flash then its a 0, next sec flash so 1 for that bit and so on? I'm not getting any responces from the device. In all probablity thats more down to my program but the lack of the address pulses is a bit of a concern. Esspecially since I've been trying to get it work for quite some time. I've had a look around on here and some other places but haven't seen anything on this particular problem. I also tried addressing the genral broadcast address 0x00 too to see if that prompted a responce to no avail. Is it syptimatic of a possible electrical connection problem?

Any ideas or suggestions or random thoughts on what it could be would be greatly appreciated.

Cheers Andy

Reply to
Dervish
Loading thread data ...

The I2C protocol is a pain in the patoosie to understand.

I worked this one out for a Microchio 24C00 EEPROM, and MAYBE it can give you some help getting the range finder working.

This is a C program that talks through a driiver (that you don't have) through the PCI bus to this EEPROM.

Ignore most of everything, and concentrate on the eeprom_* routines.

You can contact me through this newsgroup for more help.

Good luck, (get an oscilloscope or better yet, a logic analyzer) and hang in there.

We've all been here before, and when you reach the other side you'll be very happy.

/* * tl_eeprom.c * * Basic revision G card EEPROM functionality test for Unix. * * This program implements an I2C protocol clocked-serial interface to a * Microchip 24C00 128-bit serial EEPROM * * The protocol will be difficult to understand without a thorough understanding * of the I2C protocol. * * See Microchip datasheet DS21178C for a description of the 24C00 EEPROM * * * I2C is a trademark of the Philips Corporation */

#include #include #include #include #include #include "ssepci.h" #include "ssepciioctl.h" #include "tl_eeprom.h"

void eeprom_init(int fdev); void eeprom_start(int fdev); void eeprom_stop(int fdev); unsigned long eeprom_read_ioctl(int fdev); void eeprom_write_ioctl(int fdev, unsigned long val); int eeprom_write_byte(int fdev, int address, unsigned char data); unsigned char eeprom_read_byte(int fdev, unsigned int address); unsigned char eeprom_get_ack(int fdev); void eeprom_send_ack(int fdev);

int board_init(int fdev);

void main() { int fdev; char strbuffer[80]; int i;

sprintf(strbuffer, "/dev/sse%d", 0);

/* Open the device */ if ((fdev = open(strbuffer, O_RDWR)) == -1) { switch (errno) { case ENOENT: printf("Board (%s) does not exist.\n", strbuffer); break; case EBUSY: printf("Board (%s) is in use.\n", strbuffer); break; default: printf("Board (%s): open failed with error %d.\n", strbuffer, errno); } } else { printf("tl_eeprom: Checking EEPROM on device %s\n", strbuffer); board_init(fdev);

eeprom_init(fdev);

for (i = 0; i < 8; i++) eeprom_write_byte(fdev, i, 0x10 + i); for (i = 8; i < 16; i++) eeprom_write_byte(fdev, i, 0x50 + i);

for (i = 0; i < 16; i++) printf("0x%02x ", eeprom_read_byte(fdev, i)); printf("\n");

close(fdev);

} }

int board_init(int fdev) { uint32_t arg[32];

/* First get the board count */ if (ioctl(fdev, IOCTL_SSEPCI_GET_BOARDCOUNT) == -1) { printf("tl_eeprom: error getting board count\n"); return (0); } /* Soft reset */ if (ioctl(fdev, IOCTL_SSEPCI_SOFT_RESET) == -1) { printf("tl_eeprom: error in soft reset on device\n"); return (0); } /* Program the clock */ arg[0] = CLOCK_35; if (ioctl(fdev, IOCTL_SSEPCI_SET_PLL, arg, O_RDWR, NULL, NULL) == -1) { printf("tl_eeprom: error setting clock\n"); return (0); } return(1); }

/*****************/ void eeprom_init(fdev) { eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_HIGH); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_LOW); eeprom_stop(fdev); /* Issue several stops to insure proper reset */ eeprom_stop(fdev); eeprom_stop(fdev); eeprom_stop(fdev); }

void eeprom_stop(fdev) { eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_LOW | EEPROM_SCL_LOW); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_LOW | EEPROM_SCL_HIGH); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_HIGH); }

void eeprom_start(fdev) { eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_HIGH); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_LOW | EEPROM_SCL_HIGH); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_LOW | EEPROM_SCL_LOW); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_LOW); }

void eeprom_putbyte(int fdev, unsigned char data) { int i; int bitvalue;

for (i = 0; i < 8; i++) { bitvalue = (((data & 0x80) >> 7) & 1); if (bitvalue == 1) { eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_LOW); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_HIGH); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_HIGH | EEPROM_SCL_LOW); } else { eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_LOW | EEPROM_SCL_LOW); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_LOW | EEPROM_SCL_HIGH); eeprom_write_ioctl(fdev, EEPROM_SDA_ENABLE | EEPROM_SDA_LOW | EEPROM_SCL_LOW); } data

Reply to
Alan Kilian

Andy,

You see normal behaviour, read:

formatting link

0 short flashes means addr 0xe0

What platform are you on? There are a lot of programming examples on Gerry's site.

As a matter of fact, he has examples for 14 different platforms!!!! Odds are, that your platform is among those.

Bram

Reply to
Bram Stolk

Excelent, thanks for that. I just wasn't sure if it was correct. You know when your developing software and keep trying differnt things and it still doesn't work you start to wonder if it's a hardware issue. Especially after awhile. But at least I now know the SRF08 isn't malfunctioning. Makes the thread title look a bit stupid tho huh? It must be my code. I'm using a HCS12 IIC module and doing it in assembler. I've had a look at some C programs which do work with the module but to my eyes my prog should do the same really. So I'll just need to keep trying I guess. Thanks for the help tho guys.

Reply to
Dervish

I got it ranging! Finally! Seriously I'm exstatic!!! Who of ever thought that a little LED flashing to show it's ranging whould evr bring someone so much joy? Robotics you gotta love it! :)

Thanks for the tips guys, if I didn't know that LED flashing at the start was normal I probebly wouldn't of kept trying for awhile. Cheers guys.

Reply to
Dervish

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.