Page 1 of 1

MOD54415 I2C not working

Posted: Thu Oct 24, 2013 11:27 am
by jediengineer
Hey all - I2C question again. I'v written a demo program to test the I2C line going to my DAC. I attached the file to this thread for anyone who needs to see it. I'm having a problem - I'm not seeing any data movement through the I2C channel - nor is the SCL line doing anything. I set up a loop to constantly change the DAC, which is only running at 400kHz. The DAC does specify that it is compatible with 400kHz operation, but again, I've got no movement on my SCL line. I do have a pull up resistor on the SDA and SCL lines, 2.2k pulling up to 3.3V. Can someone tell me if I overlooked something in the setup? I'm still currently in the debug on eclipse, but haven't seen the issue yet...

Update:

I noticed my delay loops specified an int to contain the value 2500000 - this has been fixed. Still have the same problem.

I also noticed that the PinIO function for the SDA and SCL lines was incorrect - I fixed that - still not even a clock pulse..

I also fixed the address in the DAC_setup() routine.

Re: MOD54415 I2C not working

Posted: Thu Oct 24, 2013 12:28 pm
by jediengineer
Ok, so apparently the PinIO function numbers for the datasheet don't match the OS? On the datasheet, I2C0's SDA and SCL pins are "function 1", but now I have a clock signal when I changed them to "Function 3". DAC still not responding.

Re: MOD54415 I2C not working

Posted: Thu Oct 24, 2013 1:30 pm
by jediengineer
Ok, another update. So I'm getting signals now, but something looks wrong. The SCL line pauses after 9 pulses, for a duration of 3 pulses. Can this be changed in the software somehow? If you look on page 21 of the datasheet for my DAC ( http://www.analog.com/static/imported-f ... D5694R.pdf ) It shows the SCL pulse as continuous with no breaks. I've attached a picture of my scope output (sorry, old scope) showing the signal I'm reading. I'm not getting any output from the DAC at all, so I'm going to have to assume that it's wrong... Anyone know which way to go with this?

Re: MOD54415 I2C not working

Posted: Thu Oct 24, 2013 1:31 pm
by jediengineer
And sorry, that picture was much bigger than I thought it would be...

Re: MOD54415 I2C not working

Posted: Fri Oct 25, 2013 8:51 am
by jediengineer
Nevermind everyone... I solved the problem... Updated code if anyone wants to see it is attached.

Re: MOD54415 I2C not working

Posted: Fri Oct 25, 2013 9:23 am
by dciliske
Just an FYI for future reference: if you want to use a loop for a busy wait, you need to declare the control variable as 'volatile', otherwise the compiler will likely optimize the loop away.

-Dan

Re: MOD54415 I2C not working

Posted: Sat Oct 26, 2013 10:51 am
by jediengineer
Thanks Dan,
So within my while loop it should have:

for(volatile int i = 0; i < 100; i++) {}

yes?

not 100% familiar with compiler optimization yet...

Re: MOD54415 I2C not working

Posted: Sun Oct 27, 2013 8:02 am
by rnixon
I would also recommend it for variables passed between tasks, and any h/w registers or external memory locations used in any type of look. For example, reading a status register of an external device on the address/data bus.

Re: MOD54415 I2C not working

Posted: Mon Oct 28, 2013 6:44 am
by jediengineer
Yes, that I did know, and all my arrays used for gathering data from the various IO expansions have volatile TX/RX buffers.