get prescaler factor
This commit is contained in:
@@ -13,7 +13,7 @@ class Main
|
||||
{
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
|
||||
Command[] program = Parser.parser("de/darkress/pic16f84sim/TPicSim101.LST");
|
||||
Command[] program = Parser.parser("de/darkress/pic16f84sim/TestPrograms/TPicSim2.LST");
|
||||
/*for(int i = 0; i < instructions.size(); i++)
|
||||
{
|
||||
program.add(CommandDecoder.decode(instructions.get(i)));
|
||||
|
||||
@@ -121,6 +121,11 @@ public class Memory
|
||||
memory[0x8A] = data & 0x1F;
|
||||
}
|
||||
|
||||
public static int getOption()
|
||||
{
|
||||
return memory[0x81];
|
||||
}
|
||||
|
||||
public static boolean getZeroBit()
|
||||
{
|
||||
return (memory[0x03] & 0x04) == 0x04;
|
||||
|
||||
19
de/darkress/pic16f84sim/microcontroller/Timer.java
Normal file
19
de/darkress/pic16f84sim/microcontroller/Timer.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package de.darkress.pic16f84sim.microcontroller;
|
||||
|
||||
public class Timer
|
||||
{
|
||||
private boolean getPrescalerAsssignment() {
|
||||
return (Memory.getOption() & 0x08) == 0x08;
|
||||
}
|
||||
|
||||
private int getPrescalerFactor() {
|
||||
final int MULTIPLIER = 2;
|
||||
int prescalerPower = Memory.getOption() & 0x07;
|
||||
int prescaler = (int)Math.pow(2, prescalerPower);
|
||||
if(!getPrescalerAsssignment())
|
||||
{
|
||||
return prescaler * MULTIPLIER;
|
||||
}
|
||||
return prescaler;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user