Hallo!
Ich habe mal wieder ein ganz komische Problem:
Ich habe an einem Mega32 ein Grafikdisplay mit KS0108 Controller hängen. So weit so gut. Es funktioniert auch wunderbar wenn ich es alleine betreibe oder im Zusammenhang mit dem DCF77 Modul.
Nun will ich allerdings per I²C einen ADC auslesen. Sobald ich dieses mache spinnt auf einmal das LCD und macht was es will. Woran kann das liegen?
Hier mein Programm:
Code:
$regfile = "m32def.dat"
$crystal = 8000000
$lib "glcdKS108.lib"
Declare Sub Ads1100
Dim Luftdruck As String * 8
Config Sda = Portc.1
Config Scl = Portc.0
Config Timer2 = Pwm , Pwm = On , Compare Pwm = Clear Up , Prescale = 1
Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portb , Ce = 7 , Ce2 = 6 , Cd = 5 , Rd = 4 , Enable = 3 , Reset = 2
Config Dcf77 = Pinb.0 , Timer = 1
Config Date = Dmy , Separator = .
Enable Timer2
Enable Interrupts
Ocr2 = 10
Setfont Font8x8
Cls
I2cstart
I2cwbyte &B10010000 'Adresse (A0) und schreiben
I2cwbyte &B10001100 'continous conversion, 8SPS, gain 1
I2cstop
Do
Lcdat 1 , 1 , Time$
Gosub Ads1100
Lcdat 3 , 1 , "Druck: " ; Luftdruck
Loop
End
Sub Ads1100 'Subroutine für ADS1100, Ausgabe: String * 7
Local W As Word
Local U As Single
Local P As Single
I2creceive &B10010001 , W , 0 , 2 'Adresse (A0) und lesen, Daten in Variable schreiben
Rotate W , Left , 8 'Bytes in richtige Reihenfolge vertauschen
U = W * 0.000152588
Lcdat 6 , 1 , "u " ; U
P = U + 0.76
P = P / 0.005295
Lcdat 5 , 1 , "d :" ; P
Luftdruck = Fusing(p , "####.##")
End Sub
$include "font8x8.font"
Vielen Dank
Marten83
Lesezeichen