rmb Posted June 26, 2015 Report Share Posted June 26, 2015 Hi I would like to communicate with MCP4725 DAC from Papiio DUO through I2C.Is it possible to use I2C library or it could work only with WII Chuck? Thank you rmb. Quote Link to comment Share on other sites More sharing options...
Jack Gassett Posted June 26, 2015 Report Share Posted June 26, 2015 Hello rmb, The I2C library should work with any I2C device, the Wii Chuck has its own separate library that uses I2C. The Wii Chuck library actually gives you a good idea of how to use the I2C library:https://github.com/GadgetFactory/DesignLab_Examples/blob/master/libraries/WiiChuck/WiiChuck.cpp Jack. Quote Link to comment Share on other sites More sharing options...
rmb Posted June 29, 2015 Author Report Share Posted June 29, 2015 Jack, thank you for your answer.I started from simple task however no luck yet.I added I2C to wishbone 9 and attached signals to pins Arduino_7 and Arduino_6 like in provided example.For sketch I used next modified code (originally provided for Wire arduino library):#include <i2c.h>#define DAC_ADDR 0x60int lookup = 0; // indexint mysin[512] ={ 2048, 2073, 2098, 2123, 2148, 2174, 2199, 2224,… 1847, 1872, 1897, 1922, 1948, 1973, 1998, 2023};void setup() { I2C.begin(100000); I2C.enable(); }void loop() { I2C.start(DAC_ADDR,0); I2C.tx(64); I2C.tx(mysin[lookup] >> 4); I2C.tx((mysin[lookup] & 15) << 4); I2C.stop(); lookup = (lookup + 1) & 511;}Unfortunately I don’t see any activity at Pins 6 an 7.I would like to ask some questions which could help me moving forward:How need I declare in sketch that I attach I2C to wishbone 9 at ZPUino soft processor?What is second argument in function I2C.start?Thank yourmb Quote Link to comment Share on other sites More sharing options...
alvieboy Posted June 29, 2015 Report Share Posted June 29, 2015 Unfortunately I don’t see any activity at Pins 6 an 7. Hi, are your pins at logic '1' or '0' ? Do you have external pullups ? How need I declare in sketch that I attach I2C to wishbone 9 at ZPUino soft processor? No need, it will detect the slot (you should see that when you start your sketch). What is second argument in function I2C.start? If I recall well, it's how I2C handles read vs. writes (direction). See "I2C Device Addressing" here: http://www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html Quote Link to comment Share on other sites More sharing options...
Jack Gassett Posted June 29, 2015 Report Share Posted June 29, 2015 If you bring up a serial terminal at 115200 and press reset on the Papilio you should see it say that it detects the I2C device and the wishbone slot it is connected to. Jack. Quote Link to comment Share on other sites More sharing options...
rmb Posted June 30, 2015 Author Report Share Posted June 30, 2015 Gents, thank you for answers.A half issue was that probably I made some mistake when I modified ZPUino Vanilla soft processor (I attached I2C symbol to wishbone 9, remove Arduino pins 6 an 7 from WING_AL, extend I2C pins by wires, create markers to that and rename ports as Arduino_7 and Arduino_6 ). When I uploaded this to FPGA and test it with blinked pin6 sketch the pin6 change his value. It means something wrong with my modified soft processor.When I loaded circuit from of WIIChuck sketch and uploaded my I2C sketch, I see activity on pins 6 and 7. However another half issue remains unsolved. DAC does not change his output value.I suppose it is not connect with next behavior, but my question why it is happened:I saw drift of first clock pulse between 5us to 8us on oscilloscope when processor send each third byte to DAC (from 4 bytes send within loop()).Thank you.rmb Quote Link to comment Share on other sites More sharing options...
rmb Posted June 30, 2015 Author Report Share Posted June 30, 2015 I found solution for second part of issue.I need to add at least 10us delay at loop().It give me the Sin with f~4.5Hz what is compatible with arduino uno.rmb. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.