Mam pytanie odnośnie ATmegi8-16PI . Napisałem prosty programik w BASCOM wykorzystujący TIMER1 z preskalerem=1. W przerwaniu zmieniam stan jednego z pinów 1,0,1.... aby otrzymać przebieg prostokątny. Wszystko co udało mi się wydusić przy kwarcu 14MHz to na wyjściu 10µs czyli 50kHz. W związku z ty mam pytanie czy jest metoda na wyciągnięcie 200kHz na jednym pinie z ATmega8-16PI. Poniżej to co napisałem żeby sprawdzić układ. Dodam że ATmegą bawię się pierwszy raz, a do tej pory bawiłem się AT.
$regfile = "m8def.DAT"
$crystal = 14000000
Dim A As Word
Config Timer1 = Timer , Prescale = 1
On Timer1 Gen
A = 5000
Enable Timer1
Enable Interrupts
Load Timer1 , A
Config Pinb.0 = Output
Config Pind.0 = Input
Config Pind.1 = Input
Do
Set Portd.0 : Set Portd.1
If Pind.0 = 0 Then
Waitms 1
If A < 65533 Then
A = A + 1
End If
End If
If Pind.1 = 0 Then
Waitms 1
If A > 1 Then
A = A - 1
End If
End If
Loop
End
Gen:
'Toggle Portb.0
Portb.0 = 1
Load Timer1 , A
Portb.0 = 0
Return
Z instrukcją Toggle na wyjściu jest wypełnienie 50%.
Zaś z Portb.0 = 1 i Portb.0 = 0 wypełnienie jest około 15% ale czas nie ulega zmianie.
Dzięki za podpowiedzi i sugestie.
$regfile = "m8def.DAT"
$crystal = 14000000
Dim A As Word
Config Timer1 = Timer , Prescale = 1
On Timer1 Gen
A = 5000
Enable Timer1
Enable Interrupts
Load Timer1 , A
Config Pinb.0 = Output
Config Pind.0 = Input
Config Pind.1 = Input
Do
Set Portd.0 : Set Portd.1
If Pind.0 = 0 Then
Waitms 1
If A < 65533 Then
A = A + 1
End If
End If
If Pind.1 = 0 Then
Waitms 1
If A > 1 Then
A = A - 1
End If
End If
Loop
End
Gen:
'Toggle Portb.0
Portb.0 = 1
Load Timer1 , A
Portb.0 = 0
Return
Z instrukcją Toggle na wyjściu jest wypełnienie 50%.
Zaś z Portb.0 = 1 i Portb.0 = 0 wypełnienie jest około 15% ale czas nie ulega zmianie.
Dzięki za podpowiedzi i sugestie.