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)