Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

TC1321- Responding but not working

Status
Not open for further replies.

Overclocked

Member
Ive been working with the I2C Bus lately and Ive finally gotten a EEprom to do Page reads and sequential writes. I had problems with it before (wrong resistors for Pullups) but got it working, so now Ive moved on to a TC1321 10 bit DAC. The device runs at 100khz from the I2C bus, by accident I had to still set up for 400Khz..opps, but Ive changed that. I have 10k Pull ups on both SDA and SCL. Ive used the Logic tool on my Junebug and the Device IS communicating and the master is sending out data, but Its just not outputting anything on the Output Pin.

If the device doesnt send out a ACK, does the master still send out data? Included is the logic tool output.

Code:
 Device = 18F2410
Clock = 8 // 8MHz clock
Config OSC = INTIO67

Include "IntOsc8.bas"
Include "I2C.bas"
Include "usart.bas"

Dim DATA As Byte

Const DACAddress = $90
Const WriteReg = $00

DATA = 255
while true
I2C.Initialize(I2C_100_KHZ)
I2C.Start
I2C.WriteByte(DACAddress)
I2C.WriteByte(WriteReg)
I2C.WriteByte(DATA)
I2C.Stop
wend

The Device is new out of package. I made a SMD adapter for it and I made sure the pins are connected.

Link to datasheet page:
TC1321

add: I am using the Buffered output (pin 5) with nothing on the output other than a voltmeter.
 

Attachments

  • DAC2.jpg
    DAC2.jpg
    75.5 KB · Views: 128
Last edited:

Pommie

Well-Known Member
Most Helpful Member
A quick read of the data sheet suggests that the data register requires a two byte write.

something like,
Code:
I2C.Initialize(I2C_100_KHZ)
I2C.Start
I2C.WriteByte(DACAddress)
I2C.WriteByte(WriteReg)
I2C.WriteByte(DATA/4)     //top 8 bits
I2C.WriteByte(DATA*64)    //bottom two bits
I2C.Stop

You may also need to write zero to the config register in case it's in standby mode.

Mike.
 
Last edited:

Overclocked

Member
A quick read of the data sheet suggests that the data register requires a two byte write.

something like,
Code:
I2C.Initialize(I2C_100_KHZ)
I2C.Start
I2C.WriteByte(DACAddress)
I2C.WriteByte(WriteReg)
I2C.WriteByte(DATA/4)     //top 8 bits
I2C.WriteByte(DATA*64)    //bottom two bits
I2C.Stop

You may also need to write zero to the config register in case it's in standby mode.

Mike.

Changed Code Accordingly, still nothing from the output

changed code:
Code:
I2C.Initialize(I2C_100_KHZ)
DATA = 512

I2C.Start
I2C.WriteByte(DACAddress)
I2C.WriteByte(00000001)
I2C.WriteByte(00000000)
I2C.Stop
I2C.Start
I2C.WriteByte(DACAddress)
I2C.WriteByte(WriteReg)
I2C.WriteByte(DATA.byte0)
I2C.WriteByte(DATA.byte1)
I2C.Stop

Would my previous screw up (setting the bus to 400khz) have anything to do with the device not operating? Its still responding, so Im still guessing theres something Im not doing right here.
 

Pommie

Well-Known Member
Most Helpful Member
The data sheet indicates (but isn't very clear) that the first byte sent should contain bits 9-2 (Data/4) and the second byte should contain the lowest 2 bit in the topmost position (Data*64). I can't see why this isn't working. Maybe you should try writing various values to data and read them back to confirm it is in fact communicating.

Mike.
 

Pommie

Well-Known Member
Most Helpful Member
BTW, have you connected a reference voltage to Vref?

The output voltage is Vref*(Data/1024).

Mike.
 

Overclocked

Member
BTW, have you connected a reference voltage to Vref?

The output voltage is Vref*(Data/1024).

Mike.

Yes, 2.5V Reference.

This time I tried reading the device with NO prior Writes. I tried reading from the Command Register and I got my PIC to hang and do nothing. It happens when I read the byte off the Bus.

Code:
 Device = 18F2410
Clock = 8 // 8MHz clock
Config OSC = INTIO67

Include "IntOsc8.bas"
Include "I2C.bas"
Include "usart.bas"

Dim DATA As Word
Dim Value As Byte
Dim Value2 As Byte

Const DACAddress = $90
Const WriteReg = $00
Const RWCR = $01

USART.SetBaudrate(br19200)
I2C.Initialize(I2C_100_KHZ)

USART.Write("Starting I2C bus ",13, 10)
I2C.Start
I2C.WriteByte(DACAddress)
USART.Write("Address Written ",13, 10)
I2C.WriteByte(RWCR)
USART.Write("Command Register Written",13, 10)
I2C.Start
I2C.WriteByte(DACAddress+1)
USART.Write("Read Mode ",13, 10)
Value = I2C.ReadByte
I2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)      
I2C.Stop

USART.Write("Value = ", Value, 13, 10)

It will Output up to "Read Mode" and Then Just sit there and not spit out what ever the value is. Im starting to 'believe' my device is bad, but I still suspect its code. Would A Picture of the breadboard help eliminate possible errors?

ADD: Since I am reading from the Config Register, I only need to read one byte. Power on Reset Value is Normal Operation for the Shutdown bit (0).
 
Last edited:

Overclocked

Member
Well I posted today On microchip Tech Support, Im interested to see what they have to say about this...I wonder if the device is bad if they will replace it. I ordered it from Mouser, So I dont know if I would talk to mouser about it, or if Microchip will handle it.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top