get prescaler factor
This commit is contained in:
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