MOD54415 I2C not working
-
- Posts: 192
- Joined: Mon Dec 17, 2012 6:24 am
MOD54415 I2C not working
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.
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
-
- Posts: 192
- Joined: Mon Dec 17, 2012 6:24 am
Re: MOD54415 I2C not working
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.
-
- Posts: 192
- Joined: Mon Dec 17, 2012 6:24 am
Re: MOD54415 I2C not working
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 (2.11 MiB) Viewed 8249 times
-
- Posts: 192
- Joined: Mon Dec 17, 2012 6:24 am
Re: MOD54415 I2C not working
And sorry, that picture was much bigger than I thought it would be...
-
- Posts: 192
- Joined: Mon Dec 17, 2012 6:24 am
Re: MOD54415 I2C not working
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
Re: MOD54415 I2C not working
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
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc
-
- Posts: 192
- Joined: Mon Dec 17, 2012 6:24 am
Re: MOD54415 I2C not working
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...
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
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.
-
- Posts: 192
- Joined: Mon Dec 17, 2012 6:24 am
Re: MOD54415 I2C not working
Yes, that I did know, and all my arrays used for gathering data from the various IO expansions have volatile TX/RX buffers.