|
|
View previous topic :: View next topic |
Author |
Message |
oiluj
Joined: 07 Nov 2011 Posts: 2
|
Library MCP4728 D/A I2C converter |
Posted: Mon Nov 07, 2011 5:08 pm |
|
|
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
|
|
Posted: Sat Nov 12, 2011 3:33 pm |
|
|
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
|
|
Posted: Sun Nov 13, 2011 4:51 pm |
|
|
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! |
|
|
|
|
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
|