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

10 bit DAC I2C

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







10 bit DAC I2C
PostPosted: Fri Dec 05, 2003 7:36 am     Reply with quote

hi everyone!

i have a pic16f73 and a tc1321 (10bit DAC)

i'm not sure how i have to send my data to the dac.
this is my test-program which doesn't work Sad

i hope someone can help me Rolling Eyes

Code:
#include <16f73.h>
#fuses  HS,NOWDT,NOPROTECT
#use    delay(clock=1000000)   
#use    i2c(master,SCL=PIN_C3,SDA=PIN_C4)
main()
{
while(TRUE)
{
i2c_start();
i2c_write(0x90); //address
i2c_write(0x00); //command
i2c_write(0xff); //data
i2c_write(0xff); //data
i2c_stop();
}
}
[/url]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 05, 2003 1:27 pm     Reply with quote

The delay statement below is set for 1 MHz.
I suspect that it should really be 10 MHz.
Quote:
#include <16f73.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=1000000)
#use i2c(master,SCL=PIN_C3,SDA=PIN_C4)


Also:

1. Do you have pullup resistors on SCL and SDA ?
You could use 4.7K resistors.

2. Do you have a Vref voltage applied to the Vref pin of the TC1321 ?
If your Vdd is +5v, then the maximum Vref voltage can be 3.8v.
You can create the Vref voltage by using two resistors to make
a voltage divider. To start, you could just grab a 2.2K and a 3.3K
resistor. This would give you a Vref of 3.0 volts. The output
voltage swing of the TC1321 would then be from 0 to 3.0 volts.
You'll notice that Microchip shows an additional amplifier following
the TC1321 in their application circuit. That's to get the output
voltage swing back up to where you'd really like it to be, since
the TC1321 itself can't do a rail-to-rail output.

3. In your code below, you're continuously writing to the DAC.
You don't really need to do that.
Quote:
while(TRUE)
{
i2c_start();
i2c_write(0x90); //address
i2c_write(0x00); //command
i2c_write(0xff); //data
i2c_write(0xff); //data
i2c_stop();
}


It should be sufficient to just write to it once.

main()
{

i2c_start();
i2c_write(0x90); //address
i2c_write(0x00); //command
i2c_write(0xff); //data
i2c_write(0xff); //data
i2c_stop();

while(1);
}
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Dec 05, 2003 2:12 pm     Reply with quote

Personally, I dont really understand how your even working with a TC1320.... its tiny as hell... I got some samples in and hit myself in the head for not REALLY reading over the datasheet (well, they look big enough in the pic Very Happy )

If anyone is interested, Maxim makes some I2C, RailtoRail, 8/10/12 bit DACs, but in DIP sizes (8/14/16/20)...

I was wondering though, when you send command to the DAC, do you need to recieve its ACK or it that optional... Also, how long does that command last ? ie: is it momentary or does it last untill you change it or turn it off?
Guest








PostPosted: Mon Dec 08, 2003 3:39 am     Reply with quote

i have 2k2 pullups and 3v ref voltage

i've viewed scl and sda on the oscilloscope
the signal look ok

is the code really ok? i havn't used the i2c befor Confused
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