Pin-Timer + PreScaler
This commit is contained in:
@ -30,14 +30,8 @@ public class PreScaler {
|
||||
scaler--;
|
||||
if (scaler == 0) {
|
||||
scaler = getFactor();
|
||||
Timer.incrementFromInstructionCycle();
|
||||
Timer.increment();
|
||||
}
|
||||
System.err.println("VT: " + scaler);
|
||||
}
|
||||
|
||||
public static void cycles(int i) {
|
||||
for (int j = 0; j < i; j++) {
|
||||
decrement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package fabrik.simulator.pic16f84;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class Timer {
|
||||
private static final int TIMERREG = 0x1;
|
||||
private static final int T0IF = 0x2;
|
||||
@ -25,12 +23,6 @@ public class Timer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void incrementFromInstructionCycle(){
|
||||
if (DataRegister.getDirectBit(OPTION, T0CS) == 0){
|
||||
increment();
|
||||
}
|
||||
}
|
||||
|
||||
public static void incrementFromPin (int register){
|
||||
if (DataRegister.getDirectBit(OPTION, T0CS) == 1){
|
||||
int newpin = (register >> 4) & 1;
|
||||
@ -39,12 +31,18 @@ public class Timer {
|
||||
if (DataRegister.getDirectBit(OPTION, T0SE) == 0) {
|
||||
// Low to high
|
||||
if (newpin == 1 && oldpin == 0) {
|
||||
increment();
|
||||
if (PreScaler.isPrescalerOnTimer())
|
||||
PreScaler.decrement();
|
||||
else
|
||||
increment();
|
||||
}
|
||||
} else {
|
||||
// High to low
|
||||
if (newpin == 0 && oldpin == 1) {
|
||||
increment();
|
||||
if (PreScaler.isPrescalerOnTimer())
|
||||
PreScaler.decrement();
|
||||
else
|
||||
increment();
|
||||
}
|
||||
}
|
||||
oldpin = newpin;
|
||||
@ -52,7 +50,7 @@ public class Timer {
|
||||
}
|
||||
}
|
||||
|
||||
private static void increment() {
|
||||
public static void increment() {
|
||||
int timer = DataRegister.getDirectRegister(TIMERREG);
|
||||
timer++;
|
||||
if (timer > 0xFF){
|
||||
|
||||
Reference in New Issue
Block a user