Hi,
deine Abfolge wiederholt sich so regelmäßig, dass ich das Problem in Code umsetzen würde:
Braucht nur 14% vom Mega8.Code:$regfile "m8def.dat" $crystal = 1000000 Config Portc = Output Dim Bit0 As Byte , Bit1 As Byte , Bit2 As Byte Dim Bit3 As Byte , Bit4 As Byte , Bit5 As Byte Dim Bit6 As Byte , Bit7 As Byte , Bit8 As Byte Dim Bit0_max As Byte , Bit1_max As Byte , Bit2_max As Byte Dim Bit3_max As Byte , Bit4_max As Byte , Bit5_max As Byte Dim Bit6_max As Byte , Bit7_max As Byte , Bit8_max As Byte Dim Bit0_array(8) As Byte , Bit1_array(8) As Byte , Bit2_array(18) As Byte Dim Bit3_array(12) As Byte , Bit4_array(18) As Byte , Bit5_array(30) As Byte Dim Bit6_array(10) As Byte , Bit7_array(30) As Byte , Bit8_array(30) As Byte Dim Port_c As Byte Dim Change_state As Byte Dim Timer0_ovfl As Byte Dim Cycle As Byte Config Timer0 = Timer , Prescale = 1024 On Timer0 Timer0_isr Timer0_startwert Alias 8 '1.000.000/1024/(256-8=244)/2 ~ 1 x pro Sekunde, entspricht waitms 1000 Timer0 = Timer0_startwert Enable Timer0 Enable Interrupts Portc = &B01010101 Change_state = Portc Change_state = Change_state And &HF0 Bit0_array(1) = 1 Bit0_array(2) = 1 Bit1_array(5) = 1 Bit1_array(6) = 1 Bit1_array(7) = 1 Bit1_array(8) = 1 Bit2_array(3) = 1 Bit2_array(4) = 1 Bit2_array(9) = 1 Bit2_array(10) = 1 Bit3_array(3) = 1 Bit3_array(4) = 1 Bit3_array(5) = 1 Bit3_array(6) = 1 Bit3_array(7) = 1 Bit3_array(8) = 1 Bit3_array(9) = 1 Bit3_array(10) = 1 Bit3_array(11) = 1 Bit3_array(12) = 1 Bit4_array(1) = 1 Bit4_array(2) = 1 Bit4_array(7) = 1 Bit4_array(8) = 1 Bit5_array(1) = 1 Bit5_array(2) = 1 Bit5_array(15) = 1 Bit5_array(16) = 1 Bit6_array(3) = 1 Bit6_array(4) = 1 Bit6_array(5) = 1 Bit6_array(6) = 1 Bit6_array(7) = 1 Bit6_array(8) = 1 Bit6_array(9) = 1 Bit6_array(10) = 1 Bit7_array(1) = 1 Bit7_array(2) = 1 Bit7_array(7) = 1 Bit7_array(8) = 1 Bit7_array(17) = 1 Bit7_array(18) = 1 Bit8_array(1) = 1 Bit8_array(2) = 1 Bit8_array(3) = 1 Bit8_array(4) = 1 Bit8_array(11) = 1 Bit8_array(12) = 1 Bit8_array(13) = 1 Bit8_array(14) = 1 Bit0_max = 8 Bit1_max = 8 Bit2_max = 18 Bit3_max = 12 Bit4_max = 18 Bit5_max = 30 Bit6_max = 10 Bit7_max = 30 Bit8_max = 30 Do If Change_state = 1 Then Incr Cycle Incr Bit0 If Bit0 > Bit0_max Then Bit0 = 1 Port_c.0 = Bit0_array(bit0) Incr Bit1 If Bit1 > Bit1_max Then Bit1 = 1 Port_c.1 = Bit1_array(bit1) Incr Bit2 If Bit2 > Bit2_max Then Bit2 = 1 Port_c.2 = Bit2_array(bit2) Incr Bit3 If Bit3 > Bit3_max Then Bit3 = 1 Port_c.3 = Bit3_array(bit3) Incr Bit4 If Bit4 > Bit4_max Then Bit4 = 1 Port_c.4 = Bit4_array(bit4) Incr Bit5 If Bit5 > Bit5_max Then Bit5 = 1 Port_c.5 = Bit5_array(bit5) Incr Bit6 If Bit6 > Bit6_max Then Bit6 = 1 Port_c.6 = Bit6_array(bit6) Incr Bit7 If Bit7 > Bit7_max Then Bit7 = 1 Port_c.7 = Bit7_array(bit7) Incr Bit8 If Bit8 > Bit8_max Then Bit8 = 1 'Print Cycle ; " " ; Bin(port_c) ; Bit8_array(bit8) Portb.0 = Bit8_array(bit8) Portc = Port_c Change_state = 0 End If Loop End Timer0_isr: Timer0 = Timer0_startwert Incr Timer0_ovfl If Timer0_ovfl = 2 Then Timer0_ovfl = 0 Change_state = 1 End If Return
Der Timer0 sorgt dafür, dass alle 0,5 sec ein Wechsel stattfindet. Du kannst aleso in der Do-Schleife noch andere Sachen machen, die den Takt nicht stören werden.
In deinem Code hast du Waitms = 1000 geschrieben, aber sonst immer nach 0,5 sec einen Wechsel gefordert. Wenn du doch 1000 brauchst, musst du die 2 in der ISR auf 4 setzen.
Ich bin mir auch nicht sicher, ob ich die richtige Reihe für PortB.0 genommen habe. Auch nicht, ob PortC richtig herum ist. Evtl. musst du die dann noch tauschen.
Gruß
Rolf







Zitieren
Lesezeichen