![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
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 Link to datasheet page: TC1321 add: I am using the Buffered output (pin 5) with nothing on the output other than a voltmeter.
__________________ I believe that you're wrong. Insinuating that they hold the bomb. --- Last edited by Overclocked; 30th May 2009 at 04:20 AM. | |
| |
| | #2 |
|
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 Mike. Last edited by Pommie; 30th May 2009 at 04:45 AM. | |
| |
| | #3 | |
| Quote:
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
__________________ I believe that you're wrong. Insinuating that they hold the bomb. --- | ||
| |
| | #4 |
|
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. | |
| |
| | #5 |
|
BTW, have you connected a reference voltage to Vref? The output voltage is Vref*(Data/1024). Mike. | |
| |
| | #6 | |
| Quote:
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)
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. | ||
| |
| | #7 |
|
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. --- | |
| |
|
| 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 |