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

MAX517 DAC

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



Joined: 02 Jul 2012
Posts: 3

View user's profile Send private message

MAX517 DAC
PostPosted: Mon Jul 02, 2012 12:39 pm     Reply with quote

I'm trying to make a DAC using a MAX517 with PIC18F6622. Could somebody provide me with a working code?
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Jul 02, 2012 3:19 pm     Reply with quote

Hi,

Setup your I2C communications like this:

Code:

#define MAX517_SCL PIN_A0      // Serial Clock signal to the MAX517
#define MAX517_SDA PIN_A1      // Serial Data signal to the MAX51

//-----< I2C Port Definition >-----
#use i2c(master, sda=MAX517_SDA, scl=MAX517_SCL, FAST)


Use whatever I/O pins you want, and be sure to use appropriate pull-up resistors on the SCL ans SDA lines. 4.7K works well.

and send data to the MAX517 like this:

Code:

write_dac(128); //set D/A to 2.5V


Here is the subroutine that controls the MAX517:

Code:

// This routine receives a byte from Main, and sends it out to the MAX517
// D-to-A converter. The range of the input is 0 to 255, which corresponds
// to an output voltage of 0 to 5V.
 
void write_dac(int data_out)
{
    i2c_start();
    i2c_write(0x58);          // Device address when AD0 and AD1 are tied to ground
    i2c_write(0);
    i2c_write(data_out);      // Send the data to the device
    i2c_stop();
}


Good Luck!

John


Last edited by ezflyr on Mon Jul 02, 2012 8:12 pm; edited 1 time in total
oanguloc



Joined: 02 Jul 2012
Posts: 3

View user's profile Send private message

PostPosted: Mon Jul 02, 2012 3:54 pm     Reply with quote

Thank you very, John. It is nice found people like you.
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