Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: I2C sample code rewriting in Wire on: November 16, 2012, 11:49:56 am
Now it works. I didn't know that read/write bits are set by the library. Another problem was the endTransmission. In Arduino v1.0.1 this method can be called with the false flag. So no stop condition is sent.

Device address is 0x44.

Code:
byte get_register(byte memory_address) {
  Wire.beginTransmission(DEVICE_ADDRESS);
  Wire.write(memory_address);
  Wire.endTransmission(false);
  Wire.requestFrom(DEVICE_ADDRESS, 1);
  if (Wire.available() > 0) {
    return Wire.read();
  }
  return 0;
}

Thanks again for your help.
2  Using Arduino / Networking, Protocols, and Devices / Re: I2C sample code rewriting in Wire on: November 16, 2012, 02:38:36 am
Unfortunately the code does not work. There's always a "0" returning.
Where do I have to write the control bytes?
And how can a repeated start be done?
3  Using Arduino / Networking, Protocols, and Devices / Re: I2C sample code rewriting in Wire on: November 14, 2012, 03:00:37 pm
Hi pylon,

Thank you for your answer. I saw that I posted the wrong code snippet.
The datasheet tells to handle readings as follows:
- Send control byte with LSB = 0
- Send memory address
- Generate restart
- Send control byte with LSB = 1
- Read register value

How can this be done with Wire?

Screenshot of the relevant section in the datasheet:
http://www.picfront.org/d/8RO6
4  Using Arduino / Networking, Protocols, and Devices / I2C sample code rewriting in Wire on: November 14, 2012, 09:09:23 am
Hi,

I got stuck in rewriting this in Wire. Following code is for reading data out of the IQS253 chip. I want adapt the code, so it is then implemented against the Wire library. Can somebody please help me?

Code:
unsigned char i2c_read_byte(unsigned char ack)
{
  unsigned char i, receive_byte = 0;
  I2C_DATA_IN_FLOAT;     // Set I2C DATA pin as input and floating
  wait(2);               // Wait two I2C clock cycles
  for (i = 8; i > 0; i--) // Loop and read 8 bits from I2C DATA pin
  {
    wait(2);             // Wait two I2C clock cycles
    I2C_CLK_IN_FLOAT;    // Set I2C CLK pin as input and floating
    while(!I2C_CLK_IN);  // Wait for I2C CLK line low (clock stretching)
    if (I2C_DATA_IN) receive_byte |= (1 << (i - 1)); //Read data from I2C DATA pin
    wait(1);             // Wait one I2C clock cycle
    I2C_CLK_OUT_PP_LOW;  // Set I2C CLK pin as output (push-pull) and floating
  }
  wait(1);               // Wait one I2C clock cycle
  if (ack == 0) I2C_DATA_IN_FLOAT; //
  else I2C_DATA_OUT_PP_LOW; //Send acknowledge if required
  wait(2);               // Wait two I2C clock cycles
  I2C_CLK_IN_FLOAT;      // Set I2C CLK pin as input and floating
  while(!I2C_CLK_IN);    // Wait for I2C CLK pin low (clock stretching)
  wait(2);               // Wait two I2C clock cycles
  I2C_CLK_OUT_PP_LOW;    // Set I2C CLK pin as output (push-pull) and floating
  wait(2);               // Wait two I2C clock cycles
  I2C_DATA_IN_FLOAT;     // Set I2C DATA pin as input and floating
  return receive_byte;
}
5  Using Arduino / Installation & Troubleshooting / Installation Script for Arduino UNO, ... (Microsoft Windows) on: February 20, 2012, 05:45:52 pm
Hi everybody,

I'm trying to find a way to install the new Arduino Drivers automatically.
For example with an installer or by calling a command line like
rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 .\Arduino UNO.inf

I have no success and also did not find any helpful hints.

Can somebody help me?

Thanks,
Mick
6  Forum 2005-2010 (read only) / Deutsch / Audio Input mit Peak Erkennung on: March 07, 2010, 03:16:38 am
Hallo zusammen

Momentan bin ich mit einem Projekt beschäftigt, das Audiosignale (Peaks) in MIDI umwandelt. Dabei soll die Software erkennen, wann und in welcher Intensität ein Ereignis über einen Line Input auftritt.
Dadurch wäre es möglich, einem Live abmikrofonierten Schlagzeug, MIDI gesteuerte Samples beizumischen.
Hat jemand einen Vorschlag für einen möglichen Programmcode?

Vielen Dank  
7  Forum 2005-2010 (read only) / Exhibition / Re: PWM Through a 74HC595 Shift Register on: March 14, 2010, 05:21:39 am
Hi,

You defined Ports 10, 11, 13 for running the code. I tried to use ports 2,3,4 but didn't get it to work. Is this somehow achievable?

Thank you very much!

Pages: [1]