I2C and Breakout Board
Cenlasoft
Posts: 265
Hello,
I am trying to learn I2C. I bought from sparkfun a DS1007 breakout board: http://www.sparkfun.com/commerce/product_info.php?products_id=9116
I read the datasheet and was confused. I want to use Spin to create a frequency generator (squarewave) to excite LC circuits. Is there a sample for me to start with? I know I can produce a squarewave from a prop pin, but I figure since I want to use my cool new breakout board, the prop would be perfect. Can someone tell me want part of the DS1007 datasheet data is needed for me to control and set the chip?
Thanks,
Curtis
I am trying to learn I2C. I bought from sparkfun a DS1007 breakout board: http://www.sparkfun.com/commerce/product_info.php?products_id=9116
I read the datasheet and was confused. I want to use Spin to create a frequency generator (squarewave) to excite LC circuits. Is there a sample for me to start with? I know I can produce a squarewave from a prop pin, but I figure since I want to use my cool new breakout board, the prop would be perfect. Can someone tell me want part of the DS1007 datasheet data is needed for me to control and set the chip?
Thanks,
Curtis
Comments
On the Sparkfun website there is a DS1007 code example in C that you can use as a template to translate to Spin
I tried the "i2cObjectV2" object and it worked for the eprom on my professional developers board. I put a similar eprom on the breadboard but it still used the on board eprom. Is there a way to use an extra eprom for data storage? Also I can only send my spin program to ram.
Thanks,
Curtis
You should be able to send your Spin program to the on-board EEPROM. Exactly what's happening and what do you have connected on your PDB?
I used the "i2cObjectV2" schematic for connecting the I2C devices. I connected pins 1-4 of the 32k eprom to ground and also pin 7. I connected pin 6 to pin 28 of the prop and pin 5 to pin 29 of the prop. I used two 4.7 k resistors to 3.3 v like in the "i2cObjectV2" schematic. I am trying to figure out how to use I2C and will be using it for stroage of data from the serial port. Just a test to see if it is useful and also to learn.
Thanks,
Curtis
I forgot. Also pin 8 of the eprom to 3.3V.
Thanks
Curtis
I've written my own I2C driver which, truthfully, is not dramatically different from others -- it just suits my particular style. Also, my code doesn't drive the clock line, so you must have a pull-up on the SCL pin (this is not built-in to all Propeller-based boards). You can find my I2C driver and demo here: http://obex.parallax.com/objects/528/
Perhaps looking at another (even if only slightly-different) perspective will help you get to "Aha!" Also, most I2C product documentation is pretty good about explaining the protocol for the device.
"Aha!" , I am beginning to see it. The schematic in the demo shows what I have on my Professional Development Board, my question is: is that the boot eeprom or the one I have on the board. Another question: it seems to work even though I have a 32k eeprom. Thanks, After I understand how to I2C to eeprom, I will try my hand at the DS1077 breakout board.
Thanks again,
Curtis
The program will work once after downloading to EEPROM. What happens is the program will be loaded into RAM and then run, corrupting the EEPROM. After it finishes if you press the reset button on the PPDB I'm sure you'll get bupkis. I guess this is another area to be careful of: if your EEPROM is smaller than the address range used in the code, you could truncate upper bits and overwrite something you don't want to.
Since the program is very small you can change $8000 to $7000 and $8FFF to $7FFF -- this will work properly with the 32K EEPROM without corrupting the program space. I just gave that a try and it's fine (and is easily verified by looking at the memory use of the program [noparse][[/noparse]F8]).
It seems to work with the corrections. I wanted to test if it was the 32k eeprom I put on the breadboard or the one on the PPB. I unhooked pin 28 and 29 from my eeprom on the breadboard and it still worked. How can I use an external eeprom to store data?
Thanks,
Curtis
I've attached a schematic of the Propeller Platform, a board a designed for my "Spin Zone" column in Nuts & Volts magazine. U2 is the boot EEPROM and is addressed at %000; U3 is a socket for an extra EEPROM and is addressed at %001. Keep in mind that you have to incorporate the device address into the Slave ID byte of the protocol.
Post Edited (JonnyMac) : 10/23/2009 7:39:39 PM GMT
I changed the "$A0" to "$A1". Is that what you mean? From your schematic, it looks like I am hooking it up that way by putting an eeprom on the PDB. The program gives me results on the terminal only when the external eeprom is connected to oins 28 and 29 of the PPB.
Thanks,
Curtis
$A0 | (addr << 1)
So, valid IDs would be $A0, $A2, $A4, $A6, $A8, $AA, $AC, $AE
The LSB of the ID is used as the write (0) or read (1) bit.