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 support@ccsinfo.com

dac6573 support?

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



Joined: 17 Dec 2006
Posts: 4

View user's profile Send private message Send e-mail

dac6573 support?
PostPosted: Fri Dec 07, 2007 11:16 am     Reply with quote

Hi,
I'm trying to interface a dac6573 to a PIC18F4585. Has anyone got example code for this?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 07, 2007 2:51 pm     Reply with quote

I don't have this chip to test, but the following driver and test program
is based on the DAC6573 data sheet. It should be enough to get you
started.
Remember to put pull-up resistors on the SDA and SCL lines.
Code:

#include <18F4585.h>
#fuses XT,NOWDT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use i2c(Master, sda=PIN_C4, SCL=PIN_C4)

// The DAC6573 address pins A0,A1,A2,A3 must all
// be connected to ground.
#define DAC6573_I2C_WRT_ADDR  0x98
#define DAC6573_I2C_READ_ADDR 0x99
#define DAC6573_UPDATE_CMD    0x10

// Function parameters --
// Channel: 0 to 3.
// Data: 0 to 1023.
void DAC6573_write(int8 channel, int16 data)
{
 int8 command;

 // Format the channel select bits into the command byte.
 command = ((channel & 3) << 1) | DAC6573_UPDATE_CMD;
 
 i2c_start();
 i2c_write(DAC6573_I2C_WRT_ADDR);
 i2c_write(command);
 i2c_write(data >> 8);   // Write MSB
 i2c_write(data);        // Write LSB
 i2c_stop();
}

//======================================
void main()
{

// Set channel 0 to the mid-range output voltage.
DAC6573_write(0, 512); 

while(1);
}
breeyet



Joined: 17 Dec 2006
Posts: 4

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 07, 2007 5:07 pm     Reply with quote

Wow, that was quick. Thanks for the help, I'll try it out as soon as I can and post the results.
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