'//////////////////////////////////////////////////////////////////// '/// FastAVR Basic Compiler by MICRODESIGN, www.FastAVR.com /// '/// LCD I2C clock using PCF8583 /// '/// Clock8583.bas /// '//////////////////////////////////////////////////////////////////// $Device = m128 $Stack = 32 $Clock = 7.3728 $I2C SDA=PORTD.1, SCL=PORTD.0 $Baud=9600 $LeadChar=" ", Format(3,2) Dim MsbData As Byte, LsbData As Byte Dim temp As Integer Const CntReg=&hac, StartConv=&h51, ReadT=&haa I2Cstart &h90 I2Cwrite CntReg ' acces to control register I2Cwrite &h85 ' set 10bit resolution (&h89=11bits) I2Cstop Do WaitMs 200 ' I2Cstart &h90 I2Cwrite ReadT MsbData=I2Cread, Ack LsbData=I2Cread, Nack I2Cstop I2Cstart &h90 ' start new conversion I2Cwrite StartConv I2Cstop temp=MakeWord(MsbData, LsbData) Shift(Right, 6, temp) If temp.9 Then temp=temp Or &hfc00 temp=temp*25 Print "T="; temp Loop