I'm trying to simulate the 169 using simulavr, and I have trouble with timer2

timer2 is an 8 bit timer, with an asynchroneous input, and a prescaler,
so I use timerprescalerasync

timer8_1C has hardocded registers like TCCR, TCNT, OCRA, OCRB
whereas timer2 uses TCCR2A, TCNT2, OCR2A, OCR2B
I wonder how specifying the register names for the timers
should be added to the hwtimer code...
(I'm trying the following construct, but it's a bit of a hack:
unit==2?"TCCR2A":"TCCR" etc)

also, there is a problem with the fact that the prescaler is
runningasynchroneously:
the check in isClock(cs) should probably only return true on rising edges...
(still need to look into this one too)

the case at hand is running the async clock (on pin TOSC1) at 32768 Hz,
prescaling down, then triggering timer2 overflow to run timer2_ovf_vect at 1Hz.


    tosc1 = new PinAtPort(portx, 1);
    RegisterPin("TOSC1", &tosc1->GetPin());
    prescaler2 = new HWPrescalerAsync(this, "2", *tosc1, assr_reg, 3,
gtccr_reg, 1);

    timer2irq = new TimerIRQRegister(this, irqSystem, -2);
    timer2irq->registerLine(0, new IRQLine("TOV2", 5));
    timer2irq->registerLine(1, new IRQLine("OCF2", 4));

    timer2 = new HWTimer8_1C(this,
                             new PrescalerMultiplexer(prescaler2),
                             2,
                             timer2irq->getLine("TOV2"),
                             timer2irq->getLine("OCF2"),
                             new PinAtPort(portb, 7));

_______________________________________________
Simulavr-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/simulavr-devel

Reply via email to