MOD54415 I2C not working

for everything else
Post Reply
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

MOD54415 I2C not working

Post 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.
Attachments
main.cpp
(6.87 KiB) Downloaded 531 times
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 I2C not working

Post 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.
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 I2C not working

Post 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?
Attachments
IMG_20131024_155912.jpg
IMG_20131024_155912.jpg (2.11 MiB) Viewed 8253 times
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 I2C not working

Post by jediengineer »

And sorry, that picture was much bigger than I thought it would be...
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 I2C not working

Post by jediengineer »

Nevermind everyone... I solved the problem... Updated code if anyone wants to see it is attached.
Attachments
main.cpp
(6.88 KiB) Downloaded 531 times
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: MOD54415 I2C not working

Post 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
Dan Ciliske
Project Engineer
Netburner, Inc
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 I2C not working

Post 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...
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: MOD54415 I2C not working

Post 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.
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 I2C not working

Post 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.
Post Reply