Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 30th May 2009, 04:07 AM   #1
Default TC1321- Responding but not working

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.
Attached Thumbnails
TC1321- Responding but not working-dac2.jpg  
__________________
I believe that you're wrong.
Insinuating that they hold the bomb.
---

Last edited by Overclocked; 30th May 2009 at 04:20 AM.
Overclocked is offline  
Old 30th May 2009, 04:45 AM   #2
Default

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 by Pommie; 30th May 2009 at 04:45 AM.
Pommie is online now  
Old 30th May 2009, 05:28 AM   #3
Default

Quote:
Originally Posted by Pommie View Post
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.
__________________
I believe that you're wrong.
Insinuating that they hold the bomb.
---
Overclocked is offline  
Old 30th May 2009, 05:46 AM   #4
Default

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 is online now  
Old 30th May 2009, 05:52 AM   #5
Default

BTW, have you connected a reference voltage to Vref?

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

Mike.
Pommie is online now  
Old 30th May 2009, 05:53 PM   #6
Default

Quote:
Originally Posted by Pommie View Post
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).
__________________
I believe that you're wrong.
Insinuating that they hold the bomb.
---

Last edited by Overclocked; 30th May 2009 at 05:58 PM.
Overclocked is offline  
Old 31st May 2009, 09:37 PM   #7
Default

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.
__________________
I believe that you're wrong.
Insinuating that they hold the bomb.
---
Overclocked is offline  
Reply

Tags
responding, tc1321, working

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
My LCD is working. aljamri Micro Controllers 18 25th December 2008 04:11 PM
RA4 not working??? Alverick Micro Controllers 7 3rd September 2007 12:19 PM
Why isn't this working? Glacius Micro Controllers 33 19th June 2007 07:17 AM
Working of LC as a vco.. dineshbabumm General Electronics Chat 2 6th August 2006 12:45 PM
Ra4 not working i2c2k Micro Controllers 2 7th June 2004 04:01 AM



All times are GMT. The time now is 06:16 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker