system
July 17, 2011, 8:19pm
#1
I followed the instructions per my I2C DAC's datasheet to change it to fast mode, and upped the I2C frequency by adding this line to my code:
#define TWI_FREQ 1000000L
(1Mhz).
However, when timing data transfers with the micros() function, it still takes 8 microseconds, regardless of the frequency.
Thanks!
baum
system
July 17, 2011, 9:16pm
#2
First, count the number of zeros. The value you specified does not match your comment.
Second, the micros() function increments in 4 microsecond increments. It makes a lousy timer for things that happen as rapidly as I2C.
system
July 17, 2011, 9:18pm
#3
I count 6 zeros (1,000,000), but thanks for the help with micros()! is there any other way of timing? Can I count the clk cycles a certain instruction takes?
baum
Can I count the clk cycles a certain instruction takes?
Nearly all AVR machine instructions take a single 62.5nsec clock cycle when running the chip at 16Mhz.
Lefty
system
July 17, 2011, 9:24pm
#5
Alright, but that doesn’t solve the problem… I can’t change the speed!
system
July 18, 2011, 1:21pm
#6
I thought the datasheet limits the I2C frequency to 400kHz?
system
July 18, 2011, 1:40pm
#8
My DAC supports "High-speed" mode, max. freq. 3.4Mhz. (http://www.sparkfun.com/datasheets/BreakoutBoards/MCP4725.pdf )
What datasheet are you talking about?
baum
system
July 18, 2011, 1:42pm
#9
The DAC may support higher speeds but the clock signal is generated from the master (Arduino) which only supports speeds up to 400kHz.
system
July 18, 2011, 1:47pm
#10
Oh... where does it say this?
system
July 18, 2011, 1:52pm
#12
OK. I'll keep it at 400khz, which will take 40us to transfer 2 bytes, max update frequency is 25khz... do you think this is fast enough for 22khz wav, or should I use a parallel DAC?
baum
system
July 18, 2011, 2:01pm
#13
I'll keep it at 400khz, which will take 40us to transfer 2 bytes, max update frequency is 25khz.
I make it more like 20kHz.
Don't forget start and stop bits.
system
July 18, 2011, 2:03pm
#14
The DAC allows be to continuously clock out two bytes of data, no start and stop bits needed. Though I did forget about the Ack bit between each byte... I'll go with the parallel DAC, then.
Thanks for the help!
baum