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

Library MCP4728 D/A I2C converter

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



Joined: 07 Nov 2011
Posts: 2

View user's profile Send private message

Library MCP4728 D/A I2C converter
PostPosted: Mon Nov 07, 2011 5:08 pm     Reply with quote

Hi,

I'm a student of Electrical Engineering in UFSJ, Brazil.
And I need write a program for communicates PIC18F4550 with MCP4728 D/A converter,
but I didn't find libraries for the converter.
I'd like if possible that someone posted the library for me.

Thanks all.
n-squared



Joined: 03 Oct 2006
Posts: 99

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Nov 12, 2011 3:33 pm     Reply with quote

Hi
I use the MCP4728 with the following code.


Code:


//----------------------------------------------------------------------------

#define AOUT_BUSY PIN_A3 // change to reflect YOUR hardware
#define AOUT_SDA  PIN_F2
#define AOUT_SCL  PIN_F1

#use I2C(master, scl=AOUT_SCL, sda=AOUT_SDA, fast,stream=AOUT)


void set_analog_output(int8 channel, int16 value)
  {
  int1 ack;
  i2c_start(AOUT);
  ack = i2c_write(AOUT, 0xC0);
  ack = i2c_write(AOUT, 0x58 + (channel << 1));
  ack = i2c_write(AOUT, make8(value,1));
  ack = i2c_write(AOUT, make8(value,0));
  i2c_stop(AOUT);
  }




BR
NN
_________________
Every solution has a problem.
oiluj



Joined: 07 Nov 2011
Posts: 2

View user's profile Send private message

PostPosted: Sun Nov 13, 2011 4:51 pm     Reply with quote

Hi,

I wrote this code for comunicate with MCP4728:

Code:
void mcp4728_set_voltage(int speedA,int speedB, int speedC, int speedD )
{
  conversion(speedA, speedB, speedC, speedD);

  i2c_start();
  i2c_write(0xC0);            // I2C write address
  i2c_write(0x50);            //Modo de Escrita e Canal de Inicio
  i2c_write(dadoA);
  i2c_write(tensaolsbA);
  i2c_write(dadoB);
  i2c_write(tensaolsbB);
  i2c_write(dadoC);
  i2c_write(tensaolsbC);
  i2c_write(dadoD);
  i2c_write(tensaolsbD);
  i2c_stop();
}


Do you think this code is correct??

Thanks!
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