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

Working Example for DAC output using MAX517

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

Working Example for DAC output using MAX517
PostPosted: Fri Feb 24, 2006 5:24 pm     Reply with quote

I took about 2 days to get this DAC up..due to the unnecessary mistake I made.
Hopefully, the following code sample and diagram will save your time of developement......


Sonic Smile
(I am greatful to the gurus who always stay by me for my never ending questions)


You can go to my deveoplement thread for more reading...how I did it..
http://www.ccsinfo.com/forum/viewtopic.php?p=59569#59569


Last edited by sonicdeejay on Fri Feb 24, 2006 6:35 pm; edited 2 times in total
sonicdeejay



Joined: 20 Dec 2005
Posts: 112

View user's profile Send private message

PostPosted: Fri Feb 24, 2006 5:26 pm     Reply with quote

Schematic Diagram




main program

Code:
#include <18F2525.h> // Call for PIC18F2525 Driver
#device ICD=TRUE
#device ADC=10 // Use 10bits ADC
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000) // 16Mhz Crystal is Used

#include <MAX517mod.c>  //Call for MAX517mod.c function

//Start main program
 void main()

{

  while(1)
   {

      output_high(PIN_A0); //LED ON
      write_dac(0xFF);     //DAC output 5V
      delay_ms(5000);    //Delay

      output_low(PIN_A0); //LED OFF
      write_dac(0x00);   //DAC output 0V
      delay_ms(5000);    //Delay
           
   }
   

}



MAX517mod.c (It is same with MAX517.c and the only difference is PIN assignments)

Code:
#ifndef MAX517_SDA

#define MAX517_SDA    PIN_C4  //PIN assignment for PIC18F2525
#define MAX517_CLK    PIN_C3  //PIN assignment for PIC18F2525

#endif

#use i2c(master, sda=MAX517_SDA, scl=MAX517_CLK, FAST)


void write_dac(int data_byte) {

 i2c_start();
 i2c_write(0x58);           // AD0 and AD1 are tied to ground
 i2c_write(0);
 i2c_write(data_byte);      // Send the data to the device
 i2c_stop();
}


Wink
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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