rmb

Recommended Posts

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.

Link to comment
Share on other sites

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 0x60

int lookup = 0; // index

int 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 you

rmb

Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.