Hi ,
I made a circuit with a ATMega8 to measure temperatur and oxygen , then I show the data on a lcd , this works .
Now I want to send the data via serial uart to an other ATMega8 and show the data then on a lcd .
The LCD shows the comments but then data's are scrap . Does someone see my mistake ? I found some post about serial receiving but I do not understand them .
Transmit unit
[code:1:2a4ae4de13]
' $sim ' Auskommentieren für das echte Programm
$regfile = "m8def.dat"
$crystal = 1000000
$hwstack = 32
$swstack = 32
$framesize = 40
$Baud = 4800
Config Watchdog = 2048
Start Watchdog
'config input / output
Ddrc = &B11000000
Ddrb = &B00000110
Config Portd.6 = Input
Config Portd.7 = Input
Jumper1 Alias Pind.6
Jumper2 Alias Pind.7
Taster2 Alias Pinc.2
Taster3 Alias Pinc.3
Taster4 Alias Pinc.4
Taster5 Alias Pinc.5
'Pullup
Portd.7 = 1
Portd.6 = 1
Portc.2 = 1
Portc.3 = 1
Portc.4 = 1
Portc.5 = 1
Config Adc = Single , Prescaler = Auto , Reference = Internal
Dim X As Word , Unt As Byte , Ob As Byte , Y As Word
Dim Temp As Byte
Dim Ee_unt As Eram Byte , Ee_ob As Eram Byte
Dim Xstr as String * 4 , Ystr as String * 4
Unt = Ee_unt
Ob = Ee_ob
Start Adc
Do
' Anzeige Abgastemperatur
Y = Getadc(1)
Waitms 100
' Normalbetrieb Sauerstoffmessung
X = Getadc(0)
X = X / 4
If X < Unt Then
Portb.2 = 1
Else
Portb.2 = 0
End If
If X < Ob Then
Portb.1 = 1
Else
Portb.1 = 0
End If
'Übergabe an serielles Display
Ystr = STR(Y)
Xstr = STR(X)
Ystr = Format(Ystr , "000")
Xstr = Format(Xstr , "00,0")
Print Y ,"............." ,X
'enter setup Sauerstoffgrenzwert
If Jumper1 = 0 Then
Locate 1 , 1
Lcd "Schaltpkt1=" ; Unt ; " "
Locate 2 , 1
Lcd "Schaltpkt2=" ; Ob ; " "
Do
Reset Watchdog
'Taster Schaltpunkt 1 aufwärts
If Taster2 = 0 Then
Waitms 30
Unt = Unt + 1
Waitms 100
End If
If Unt > 150 Then Unt = 150
'Taster Schaltpunkt 1 abwärts
If Taster3 = 0 Then
Waitms 30
Unt = Unt - 1
Waitms 100
End If
If Unt < 1 Then Unt = 1
'Taster Schaltpunkt 2 aufwärts
If Taster4 = 0 Then
Waitms 30
Ob = Ob + 1
Waitms 100
End If
If Ob > 150 Then Ob = 150
'Taster Schaltpunkt2 abwärts
If Taster5 = 0 Then
Waitms 30
Ob = Ob - 1
Waitms 100
End If
If Ob < 1 Then Ob = 1
Print Ob ,"........" , Unt
Waitms 100
' exit setup and save to eeprom
Loop Until Jumper1 = 1
Ee_unt = Unt
Ee_ob = Ob
End If
Reset Watchdog
' Ende Einstellung Sauerstoffgrenzwert
' ************************************
Loop
End
[/code:1:2a4ae4de13]
Receiving unit
[code:1:2a4ae4de13]
' $sim ' Auskommentieren für das echte Programm
$regfile = "m8def.dat"
$crystal = 1000000
$hwstack = 32
$swstack = 32
$framesize = 40
$Baud = 4800
Config Watchdog = 2048
Start Watchdog
On URXC OnRxD
Enable URXC
Enable Interrupts
DDRB = &B11111111
DDRC = &B11111110
DDRD = &B11111111
Config Lcdpin = Pin , Rs = PortC.3 , E = PortC.1 , Db4 = PortB.5 , Db5 = PortB.4 , Db6 = PortB.3 , Db7 = PortB.2
Config Lcd = 20 * 4
Cursor Off Noblink
Dim Wert as String * 20
Dim Neustart as Byte
Locate 1,1
LCD "ANZEIGE ABGASWERTE"
Waitms 1000
CLS
Do
Locate 1,1
Lcd "ABGAS- SAUER-"
Locate 2,1
Lcd "TEMPERATUR STOFF"
Locate 4,1
Lcd "GRAD PROZENT"
Locate 3,1
If Len(Wert) > 19 Then
Lcd Wert
End If
Neustart = Neustart + 1
If Neustart > 10 Then
Goto Neustarten
End If
Reset Watchdog
Neustarten:
Waitms 1000
Loop
OnRxD:
Wert = Wert + Chr(UDR)
Return
End
[/code:1:2a4ae4de13]
Many thanks for every answer
Hans
[b:2a4ae4de13][color=red:2a4ae4de13](BASCOM-AVR version : 2.0.7.7 )[/b:2a4ae4de13][/color:2a4ae4de13]
↧