CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with I2C between PIC18F and MAX5820 (DAC)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wewa



Joined: 02 Jul 2008
Posts: 27

View user's profile Send private message

Problem with I2C between PIC18F and MAX5820 (DAC)
PostPosted: Sat Feb 14, 2009 7:59 am     Reply with quote

Hi!

I'm trying to control a MAX5820 DAC with a PIC18F4525. My problem is this doesn't work.
I've monitored SDA and SCL and it seems that the connection is ok, because MAX5820 sends the ACK bit (pulling SDA low while 9th SCL clock cycle).

Maybe something in my code is wrong. I'm very unsure about my set_DAC procedure. (And without writing something to the DAC I can't really test my get_DAC function. Maybe you can tell me whats wrong in my code.
This are my functions:
Code:
//using CCS-compiler with MPLAB

#define DAC            0x70

void set_DAC(char dac_a, char dac_b) {   //set DAC A and DAC B of MAX5820

   i2c_start();
   i2c_write(DAC|0x00);
   i2c_write(0x00|dac_a>>4);
   i2c_write(dac_a<<4);
   i2c_stop();
   
   i2c_start();
   i2c_write(DAC|0x00);
   i2c_write(0x10|dac_b>>4);
   i2c_write(dac_b<<4);
   i2c_stop();

}

char get_DAC(int1 select) {      //read DAC A or DAC B data from MAX5820
   
   char tmp=0x00;
   
   i2c_start();
   i2c_write(DAC|0x00);
   if(select) i2c_write(0xF1);   //read DAC A
   else i2c_write(0xF2);      //read DAC B
   i2c_start();
   i2c_write(DAC|0x01);
   tmp=i2c_read()<<4;
   tmp=tmp|i2c_read()>>4;
   i2c_stop();
   return tmp;

}


And here's the datasheet: http://www.farnell.com/datasheets/112025.pdf

Thanks for any help.
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Mon Feb 16, 2009 4:43 pm     Reply with quote

I haven't used this chip, but here are a few things to check.

Code:

#define DAC            0x70


This implies the MAX5820L part with the Vadd pin connected to GND.
Confirm that the reference is connected.

Guess it is possible that the DACs have been inadvertently powered down.
May need to write the powerup sequence first.
wewa



Joined: 02 Jul 2008
Posts: 27

View user's profile Send private message

PostPosted: Tue Feb 17, 2009 9:04 am     Reply with quote

Thanks for answer.

Yes the Vadd-pin is connected to ground.

Tomorrow I'll try the power-up command and report if it helps.


wewa
wewa



Joined: 02 Jul 2008
Posts: 27

View user's profile Send private message

PostPosted: Wed Feb 18, 2009 8:17 am     Reply with quote

Thanks!
You were right, the DAC was in power-down mode.
After setting in power-up mode the device works.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group