Hi Cassio,
yip, mal wieder genug geschlafen und frisch die Programme nochmal durchgegangen sowie beide Mega16 gegeneinander angeschlossen. Die UART bleibt vermatscht. Ich befürchte, die Beiden sind defekt. Da ich z. Zt. nur alk- freies Weizen trinke, scheidet dieser Punkt also aus.
Ich trau mich fast nicht, die Mega32 anzuschliesssen.
Ich habe jetzt den Lap und den kompletten Aufbau wieder oben, das Rauf- und Runterrennen nervt doch etwas.
MEGA16 - MASTER/TEST
CodeBox bascom
$regfile = "m16def.dat"
$crystal = 14745600
$baud = 115200
$hwstack = 40
$swstack = 20
$framesize = 40
'____________________________________________________________________
'_____ Compiler- Direktiven/ LIB's einbinden ______________________________
'
$LIB "mcsbyte.lbx"
'____________________________________________________________________
'_____ Ports definieren _________________________________________________
'
DDRa = &B0000_0000 ' PortA - Eingang
portb = &B1111_1111 ' Pullups aktiviert
'
DDRB = &B0000_0000 ' PortB - Eingang
portb = &B1111_1111 ' Pullups aktiviert
'
DDRC = &B0000_0000 ' PortC - Eingang
portc = &B1111_1111 ' Pullups aktiviert
'
DDRD = &B000_0010 ' PortD = Eingang
portd = &B1111_1100 ' Pullups aktiviert'
'____________________________________________________________________
'_____ Variablen - Subroutinen - Label ____________________________________
'
'Dim i as byte , avr as byte
Dim temp as integer
Dim grad as single , wert as single ', zeit1 as single , zeit2 as single
grad = 0 : temp = 0 ':zeit1 = 0 : zeit2 = 0
'____________________________________________________________________
'_____ Register _______________________________________________________
'
ADCSRA.7 = 0 : ACSR.7 = 1 : sreg.7 = 1 'ADC und Komparator aus, IRQ an
'____________________________________________________________________
'_____ Pins zuweisen __________________________________________________
'
'____________________________________________________________________
'_____ Hauptprogramm ________________________________________________
'
'config waitsuart= 1
waitms 200
''
open "comd.6:115200, 8 , n , 1" for input as #1
'open "comb.1:115200, 8 , n , 1" for output as #2
''
do
if pinD.7 = 0 then
do
inputbin #1 , grad , temp
loop until grad > 0
wert = temp
'printbin #2 , &B0000_0010 ; grad
Print
Print "ADC " ; fusing(wert , "####.") ; " = " ; fusing(grad , "##.##") ; " °C"
waitms 150
endif
loop
close #1 ' : close #2
End
MEGA16 - SLAVE/TEST
CodeBox bascom
$regfile = "m16def.dat"
$crystal = 14745600
$baud = 115200
$hwstack = 40
$swstack = 20
$framesize = 40
'____________________________________________________________________
'_____ Compiler- Direktiven/ LIB's einbinden ______________________________
'
$LIB "mcsbyte.lbx"
'____________________________________________________________________
'_____ Ports definieren _________________________________________________
'
DDRa = &B0000_0000 ' PortA - Eingang
portb = &B1111_1111 ' Pullups aktiviert
'
DDRB = &B0000_0000 ' PortB - Eingang
portb = &B1111_1111 ' Pullups aktiviert
'
DDRC = &B0000_0000 ' PortC - Eingang
portc = &B1111_1111 ' Pullups aktiviert
'
DDRD = &B010_0010 ' PortD = Eingang
portd = &B1011_1100 ' Pullups aktiviert'
'____________________________________________________________________
'_____ Variablen - Subroutinen - Label ____________________________________
'
'Dim i as byte , avr as byte
Dim temp as integer
Dim grad as single ',zeit1 as single , zeit2 as single , wert as single
grad = 21.67 : temp = 232 ':zeit1 = 0 : zeit2 = 0
'____________________________________________________________________
'_____ Register _______________________________________________________
'
ADCSRA.7 = 0 : ACSR.7 = 1 : sreg.7 = 1 'ADC und Komparator aus, IRQ an
'____________________________________________________________________
'_____ Pins zuweisen __________________________________________________
'
'____________________________________________________________________
'_____ Hauptprogramm ________________________________________________
'
'config waitsuart= 1
waitms 200
''
'open "comd.6:115200, 8 , n , 1" for input as #1
open "comd.6:115200, 8 , n , 1" for output as #2
''
do
printbin #2 , grad ; temp
waitms 500
loop
close #2 ' : close #2
End
Falls nötig, schicke ich noch die funktionierenden Codes, wird jetzt zu unübersichtlich.
Grüsse,
Michael