TMR0 works
This commit is contained in:
parent
83a0a42684
commit
405b82d086
@ -841,6 +841,11 @@ namespace PIC_Simulator.PIC
|
||||
Interrupt_RB(Register[index], (byte)wert);
|
||||
}
|
||||
|
||||
if (index == ADDR_TMR0)
|
||||
{
|
||||
Zaehler.Reset();
|
||||
}
|
||||
|
||||
Register[index] = (byte)(wert & 0xFF);
|
||||
|
||||
if (index == ADDR_PORT_A || index == ADDR_TRIS_A)
|
||||
@ -942,7 +947,7 @@ namespace PIC_Simulator.PIC
|
||||
|
||||
private void SetRegister(uint index, uint wert)
|
||||
{
|
||||
if ((Register[ADDR_STATUS] & STATUS_BIT_RP0) == STATUS_BIT_RP0)
|
||||
if (GetBit(Register[ADDR_STATUS], STATUS_BIT_RP0))
|
||||
{
|
||||
SetRegisterOhneBank(0x80 + index, wert);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace PIC_Simulator.PIC
|
||||
bool tmr_mode = programm.GetRegisterOhneBank(PICProgramm.ADDR_OPTION, PICProgramm.OPTION_BIT_T0CS);
|
||||
bool edge_mode = programm.GetRegisterOhneBank(PICProgramm.ADDR_OPTION, PICProgramm.OPTION_BIT_T0SE);
|
||||
|
||||
if (!tmr_mode)
|
||||
if (tmr_mode)
|
||||
{
|
||||
bool curr_A4 = programm.GetRegisterOhneBank(PICProgramm.ADDR_PORT_A, 4);
|
||||
|
||||
@ -43,18 +43,18 @@ namespace PIC_Simulator.PIC
|
||||
prev_RA4 = programm.GetRegisterOhneBank(PICProgramm.ADDR_PORT_A, 4);
|
||||
}
|
||||
|
||||
private uint prescale_cntr = 0; // Zähler für timer
|
||||
private uint count = 0; // Zähler für timer
|
||||
|
||||
private void TimerHochzaehlen(uint cycles)
|
||||
{
|
||||
uint current = programm.GetRegisterOhneBank(PICProgramm.ADDR_TMR0);
|
||||
uint current = programm.Register[PICProgramm.ADDR_TMR0];
|
||||
uint scale = BerechneVorskalierung();
|
||||
|
||||
prescale_cntr += cycles;
|
||||
count += cycles;
|
||||
|
||||
while (prescale_cntr >= scale)
|
||||
while (count >= scale)
|
||||
{
|
||||
prescale_cntr -= scale;
|
||||
count -= scale;
|
||||
|
||||
uint Result = current + 1;
|
||||
if (Result > 0xFF)
|
||||
@ -64,9 +64,9 @@ namespace PIC_Simulator.PIC
|
||||
|
||||
Result %= 0x100;
|
||||
|
||||
uint tmp_psc = prescale_cntr;
|
||||
programm.SetRegisterOhneBank(PICProgramm.ADDR_TMR0, Result);
|
||||
prescale_cntr = tmp_psc;
|
||||
uint tmp_psc = count;
|
||||
programm.Register[PICProgramm.ADDR_TMR0] = (byte) Result;
|
||||
count = tmp_psc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,5 +83,10 @@ namespace PIC_Simulator.PIC
|
||||
|
||||
return prescale_mode ? 1 : (PICProgramm.SHL(2, scale));
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
[X] Testprogramm 4 (DECFSZ, RLF, RRF...
|
||||
[X] Testprogramm 5 (Bitbefehle)
|
||||
[X] Testprogramm 6 (indirekte Adressierung)
|
||||
[ ] Testprogramm 7 (Timer 0 )
|
||||
[X] Testprogramm 7 (Timer 0 )
|
||||
[X] Ext. Taktgeber an RA4 + IO-Pin
|
||||
[ ] Testprogramm 7 (Interrupts)
|
||||
[ ] Testprogramm 9 (Sleep-Befehl)
|
||||
|
Loading…
Reference in New Issue
Block a user