simulavr  1.1.0
hwtimer.h
Go to the documentation of this file.
1  /*
2  ****************************************************************************
3  *
4  * simulavr - A simulator for the Atmel AVR family of microcontrollers.
5  * Copyright (C) 2001, 2002, 2003 Klaus Rudolph
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  ****************************************************************************
22  *
23  * $Id$
24  */
25 
26 #ifndef HWTIMER
27 #define HWTIMER
28 
29 #include "hardware.h"
30 #include "pinatport.h"
31 #include "rwmem.h"
32 #include "prescalermux.h"
33 #include "timerirq.h"
34 #include "traceval.h"
35 #include "icapturesrc.h"
36 
38  public:
39  virtual void fireEvent(int event) = 0;
40 
41  virtual ~TimerEventListener() {}
42 };
43 
45 
49 
50  private:
51  int cs;
55  bool icapNCstate;
57 
58  public:
60  enum CEtype {
61  EVT_TOP_REACHED = 0,
67  };
68 
72  int unit,
73  IRQLine* tov,
74  IRQLine* tcap,
75  ICaptureSource* icapsrc,
76  int countersize = 8);
79  void Reset();
80 
82  virtual unsigned int CpuCycle();
83 
85  void RegisterACompForICapture(HWAcomp *acomp);
86 
88  void SetACIC(bool acic) { if(icapSource != NULL) icapSource->SetACIC(acic); }
89 
91  void SetTimerEventListener(TimerEventListener *listener) { eventListener = listener; }
92 
93  protected:
95  enum WGMtype {
96  WGM_NORMAL = 0,
112  WGM_tablesize
113  };
115  enum COMtype {
116  COM_NOOP = 0,
119  COM_SET
120  };
122  enum OCRIDXtype {
123  OCRIDX_A = 0,
126  OCRIDX_maxUnits
127  };
128  typedef void (BasicTimerUnit::*wgmfunc_t)(CEtype);
129 
134 
135  unsigned long vtcnt;
136  unsigned long vlast_tcnt;
137  // used for detection of count events, because
138  // most events occur at VALUE + 1, means, that VALUE
139  // have to appear for one count clock cycle!
141  bool count_down;
142  unsigned long limit_bottom;
143  unsigned long limit_top;
144  unsigned long limit_max;
145 
146  unsigned long icapRegister;
150 
152  wgmfunc_t wgmfunc[WGM_tablesize];
153  unsigned long compare[OCRIDX_maxUnits];
154  unsigned long compare_dbl[OCRIDX_maxUnits];
155  bool compareEnable[OCRIDX_maxUnits];
156  COMtype com[OCRIDX_maxUnits];
157  IRQLine* timerCompare[OCRIDX_maxUnits];
158  PinAtPort compare_output[OCRIDX_maxUnits];
159  bool compare_output_state[OCRIDX_maxUnits];
160 
162  void CountTimer(void);
164  virtual void InputCapture(void);
166 
170  void HandleEvent(CEtype event);
172  void SetClockMode(int _cs);
174  void SetCounter(unsigned long val);
176  void SetCompareOutputMode(int idx, COMtype mode);
178  void SetCompareOutput(int idx);
180  void SetPWMCompareOutput(int idx, bool topOrDown);
181 
183  bool WGMisPWM(void) { return wgm != WGM_NORMAL && wgm != WGM_CTC_OCRA && wgm != WGM_CTC_ICR; }
185  bool WGMuseICR(void) { return wgm == WGM_FASTPWM_ICR || wgm == WGM_CTC_ICR || wgm == WGM_PCPWM_ICR || wgm == WGM_PFCPWM_ICR; }
187  void WGMFunc_noop(CEtype event) {}
189  void WGMfunc_normal(CEtype event);
191  void WGMfunc_ctc(CEtype event);
193  void WGMfunc_fastpwm(CEtype event);
195  void WGMfunc_pcpwm(CEtype event);
197  void WGMfunc_pfcpwm(CEtype event);
198 
199 };
200 
202 class HWTimer8: public BasicTimerUnit {
203 
204  protected:
206  void ChangeWGM(WGMtype mode);
207 
209  void SetCompareRegister(int idx, unsigned char val);
211  unsigned char GetCompareRegister(int idx);
212 
214  void Set_TCNT(unsigned char val) { SetCounter(val); }
216  unsigned char Get_TCNT() { return vtcnt & 0xff; }
217 
219  void Set_OCRA(unsigned char val) { SetCompareRegister(0, val); }
221  unsigned char Get_OCRA() { return GetCompareRegister(0); }
222 
224  void Set_OCRB(unsigned char val) { SetCompareRegister(1, val); }
226  unsigned char Get_OCRB() { return GetCompareRegister(1); }
227 
228  public:
232 
233  HWTimer8(AvrDevice *core,
235  int unit,
236  IRQLine* tov,
237  IRQLine* tcompA,
238  const PinAtPort& outA,
239  IRQLine* tcompB,
240  const PinAtPort& outB);
242  void Reset();
243 };
244 
246 class HWTimer16: public BasicTimerUnit {
247 
248  protected:
250  unsigned char accessTempRegister;
251 
253  void SetCompareRegister(int idx, bool high, unsigned char val);
255  unsigned char GetCompareRegister(int idx, bool high);
257  void SetComplexRegister(bool is_icr, bool high, unsigned char val);
259  unsigned char GetComplexRegister(bool is_icr, bool high);
260 
262  void ChangeWGM(WGMtype mode);
263 
265  void Set_TCNTH(unsigned char val) { SetComplexRegister(false, true, val); }
267  unsigned char Get_TCNTH() { return GetComplexRegister(false, true); }
269  void Set_TCNTL(unsigned char val) { SetComplexRegister(false, false, val); }
271  unsigned char Get_TCNTL() { return GetComplexRegister(false, false); }
272 
274  void Set_OCRAH(unsigned char val) { SetCompareRegister(0, true, val); }
276  unsigned char Get_OCRAH() { return GetCompareRegister(0, true); }
278  void Set_OCRAL(unsigned char val) { SetCompareRegister(0, false, val); }
280  unsigned char Get_OCRAL() { return GetCompareRegister(0, false); }
281 
283  void Set_OCRBH(unsigned char val) { SetCompareRegister(1, true, val); }
285  unsigned char Get_OCRBH() { return GetCompareRegister(1, true); }
287  void Set_OCRBL(unsigned char val) { SetCompareRegister(1, false, val); }
289  unsigned char Get_OCRBL() { return GetCompareRegister(1, false); }
290 
292  void Set_OCRCH(unsigned char val) { SetCompareRegister(2, true, val); }
294  unsigned char Get_OCRCH() { return GetCompareRegister(2, true); }
296  void Set_OCRCL(unsigned char val) { SetCompareRegister(2, false, val); }
298  unsigned char Get_OCRCL() { return GetCompareRegister(2, false); }
299 
301  void Set_ICRH(unsigned char val) { SetComplexRegister(true, true, val); }
303  unsigned char Get_ICRH() { return GetComplexRegister(true, true); }
305  void Set_ICRL(unsigned char val) { SetComplexRegister(true, false, val); }
307  unsigned char Get_ICRL() { return GetComplexRegister(true, false); }
308 
309  public:
320 
321  HWTimer16(AvrDevice *core,
323  int unit,
324  IRQLine* tov,
325  IRQLine* tcompA,
326  const PinAtPort& outA,
327  IRQLine* tcompB,
328  const PinAtPort& outB,
329  IRQLine* tcompC,
330  const PinAtPort& outC,
331  IRQLine* ticap,
332  ICaptureSource* icapsrc);
334  void Reset(void);
335 };
336 
338 
347 class HWTimer8_0C: public HWTimer8 {
348 
349  protected:
350  unsigned char tccr_val;
351 
353  void Set_TCCR(unsigned char val);
355  unsigned char Get_TCCR() { return tccr_val; }
356 
357  public:
359 
360  HWTimer8_0C(AvrDevice *core,
362  int unit,
363  IRQLine* tov);
365  void Reset(void);
366 };
367 
369 
377 class HWTimer8_1C: public HWTimer8 {
378 
379  protected:
380  unsigned char tccr_val;
381 
383  void Set_TCCR(unsigned char val);
385  unsigned char Get_TCCR() { return tccr_val; }
386 
387  public:
389 
390  HWTimer8_1C(AvrDevice *core,
392  int unit,
393  IRQLine* tov,
394  IRQLine* tcompA,
395  const PinAtPort& outA);
397  void Reset(void);
398 };
399 
401 
416 class HWTimer8_2C: public HWTimer8 {
417 
418  private:
419  int wgm_raw;
420 
422  void Set_WGM(int val);
423 
424  protected:
425  unsigned char tccra_val;
426  unsigned char tccrb_val;
427 
429  void Set_TCCRA(unsigned char val);
431  unsigned char Get_TCCRA() { return tccra_val; }
432 
434  void Set_TCCRB(unsigned char val);
436  unsigned char Get_TCCRB() { return tccrb_val; }
437 
438  public:
441 
442  HWTimer8_2C(AvrDevice *core,
444  int unit,
445  IRQLine* tov,
446  IRQLine* tcompA,
447  const PinAtPort& outA,
448  IRQLine* tcompB,
449  const PinAtPort& outB);
451  void Reset(void);
452 };
453 
455 
470 class HWTimer16_1C: public HWTimer16 {
471 
472  private:
473  int wgm_raw;
474 
476  void Set_WGM(int val);
477 
478  protected:
479  unsigned char tccra_val;
480  unsigned char tccrb_val;
481 
483  void Set_TCCRA(unsigned char val);
485  unsigned char Get_TCCRA() { return tccra_val; }
486 
488  void Set_TCCRB(unsigned char val);
490  unsigned char Get_TCCRB() { return tccrb_val; }
491 
492  public:
495 
496  HWTimer16_1C(AvrDevice *core,
498  int unit,
499  IRQLine* tov,
500  IRQLine* tcompA,
501  const PinAtPort& outA,
502  IRQLine* ticap,
503  ICaptureSource* icapsrc);
505  void Reset(void);
506 };
507 
509 
528 class HWTimer16_2C2: public HWTimer16 {
529 
530  private:
531  int wgm_raw;
532  bool at8515_mode;
533 
535  void Set_WGM(int val);
536 
537  protected:
538  unsigned char tccra_val;
539  unsigned char tccrb_val;
540 
542  void Set_TCCRA(unsigned char val);
544  unsigned char Get_TCCRA() { return tccra_val; }
545 
547  void Set_TCCRB(unsigned char val);
549  unsigned char Get_TCCRB() { return tccrb_val; }
550 
551  public:
554 
555  HWTimer16_2C2(AvrDevice *core,
557  int unit,
558  IRQLine* tov,
559  IRQLine* tcompA,
560  const PinAtPort& outA,
561  IRQLine* tcompB,
562  const PinAtPort& outB,
563  IRQLine* ticap,
564  ICaptureSource* icapsrc,
565  bool is_at8515);
567  void Reset(void);
568 };
569 
571 
593 class HWTimer16_2C3: public HWTimer16 {
594 
595  protected:
596  unsigned char tccra_val;
597  unsigned char tccrb_val;
598 
600  void Set_TCCRA(unsigned char val);
602  unsigned char Get_TCCRA() { return tccra_val; }
603 
605  void Set_TCCRB(unsigned char val);
607  unsigned char Get_TCCRB() { return tccrb_val; }
608 
610  void Set_TCCRC(unsigned char val);
612  unsigned char Get_TCCRC() { return 0; } // will be read allways 0!
613 
614  public:
618 
619  HWTimer16_2C3(AvrDevice *core,
621  int unit,
622  IRQLine* tov,
623  IRQLine* tcompA,
624  const PinAtPort& outA,
625  IRQLine* tcompB,
626  const PinAtPort& outB,
627  IRQLine* ticap,
628  ICaptureSource* icapsrc);
630  void Reset(void);
631 };
632 
634 
656 class HWTimer16_3C: public HWTimer16 {
657 
658  protected:
659  unsigned char tccra_val;
660  unsigned char tccrb_val;
661 
663  void Set_TCCRA(unsigned char val);
665  unsigned char Get_TCCRA() { return tccra_val; }
666 
668  void Set_TCCRB(unsigned char val);
670  unsigned char Get_TCCRB() { return tccrb_val; }
671 
673  void Set_TCCRC(unsigned char val);
675  unsigned char Get_TCCRC() { return 0; } // will be read allways 0!
676 
677  public:
681 
682  HWTimer16_3C(AvrDevice *core,
684  int unit,
685  IRQLine* tov,
686  IRQLine* tcompA,
687  const PinAtPort& outA,
688  IRQLine* tcompB,
689  const PinAtPort& outB,
690  IRQLine* tcompC,
691  const PinAtPort& outC,
692  IRQLine* ticap,
693  ICaptureSource* icapsrc);
695  void Reset(void);
696 };
697 
699 
703  private:
706 
708  bool ocrPWM;
709  bool ocrOut;
710  int dtHigh;
711  int dtLow;
712  int dtCounter;
713 
715  void SetPWM(bool isCompareEvent);
716 
718  void SetDeadTime(bool pwmValue);
719 
720  public:
721  TimerTinyX5_OCR(const PinAtPort& pinOut, const PinAtPort& pinOutInv);
722 
724  void Reset();
725 
727  void DTClockCycle();
728 
730  void TimerEvent(bool isCompareEvent) { SetPWM(isCompareEvent); }
731 
733  void ForceEvent() { /* only, if unit isn't in PWM mode */ if(!ocrPWM) SetPWM(true); }
734 
736  void SetDeadTime(int highTime, int lowTime) { dtHigh = highTime; dtLow = lowTime; }
737 
739  void SetOCRMode(bool isPWM, int comMode);
740 };
741 
743 
747  private:
748  unsigned char inValue;
749  unsigned char regValue;
750 
751  public:
752  HWTimerTinyX5_SyncReg() { Reset(0); }
753 
755  void Reset(unsigned char v) { inValue = regValue = v; }
756 
758  unsigned char operator=(unsigned char v) { inValue = v; return v; }
759 
760 #ifndef SWIG
761  operator unsigned char() { return regValue; }
763 #endif
764 
766  unsigned char GetBusValue(void) { return inValue; }
767 
769  bool ClockAndChanged(void) { if(inValue != regValue) { regValue = inValue; return true; } return false; }
770 
772  void MaskOutSync(unsigned char mask) { inValue &= ~mask; regValue = inValue; }
773 };
774 
776 
778 class HWTimerTinyX5: public Hardware,
779  public TraceValueRegister,
780  public SimulationMember,
781  public IOSpecialRegClient {
782 
783  private:
787 
788  // counter and prescaler
789  unsigned long counter;
790  unsigned long prescaler;
791  unsigned char dtprescaler;
792 
793  // input/output values for TCCR, OCRx and input value for GTCCR
799  unsigned char dtps1_inout_val;
802 
803  // output and input register for TCNT
804  unsigned char tcnt_out_val;
805  unsigned char tcnt_out_async_tmp;
806  unsigned char tcnt_in_val;
811 
812  // internal values for TCCR, OCRx
813  unsigned char ocra_internal_val;
814  unsigned long ocra_compare;
816  unsigned char ocrb_internal_val;
817  unsigned long ocrb_compare;
821  int cfg_mode;
822  bool cfg_ctc;
823  int cfg_com_a;
824  int cfg_com_b;
825 
826  enum TMODEtype {
827  TMODE_NORMAL = 0x0,
828  TMODE_PWMA = 0x1,
829  TMODE_PWMB = 0x2
830  };
831 
832  // variables for async mode and pll
839 
840  protected:
850 
852  void Set_TCNT(unsigned char val) { tcnt_in_val = val; tcnt_set_flag = true; }
854  unsigned char Get_TCNT() { return tcnt_out_val; }
855 
857  void Set_TCCR(unsigned char val) { tccr_inout_val = val; }
859  unsigned char Get_TCCR() { return tccr_inout_val.GetBusValue(); }
860 
862  void Set_OCRA(unsigned char val) { ocra_inout_val = val; }
864  unsigned char Get_OCRA() { return ocra_inout_val.GetBusValue(); }
865 
867  void Set_OCRB(unsigned char val) { ocrb_inout_val = val; }
869  unsigned char Get_OCRB() { return ocrb_inout_val.GetBusValue(); }
870 
872  void Set_OCRC(unsigned char val) { ocrc_inout_val = val; }
874  unsigned char Get_OCRC() { return ocrc_inout_val.GetBusValue(); }
875 
877  void Set_DTPS1(unsigned char val) { dtps1_inout_val = val; }
879  unsigned char Get_DTPS1() { return dtps1_inout_val; }
880 
882  void Set_DT1A(unsigned char val) { dt1a_inout_val = val; }
884  unsigned char Get_DT1A() { return dt1a_inout_val.GetBusValue(); }
885 
887  void Set_DT1B(unsigned char val) { dt1b_inout_val = val; }
889  unsigned char Get_DT1B() { return dt1b_inout_val.GetBusValue(); }
890 
892  unsigned char set_from_reg(const IOSpecialReg *reg, unsigned char nv);
894  unsigned char get_from_client(const IOSpecialReg *reg, unsigned char v);
895 
897  void SetPrescalerClock(bool pcke);
898 
900  void TimerCounter(void);
901 
903  bool PrescalerMux(void);
904 
906  bool DeadTimePrescalerMux(void);
907 
909  void TransferInputValues(void);
910 
912  void TransferOutputValues(void);
913 
914  public:
923 
924  HWTimerTinyX5(AvrDevice *core,
925  IOSpecialReg *gtccr,
926  IOSpecialReg *pllcsr,
927  IRQLine* tov,
928  IRQLine* tocra,
929  const PinAtPort& ocra_out,
930  const PinAtPort& ocra_outinv,
931  IRQLine* tocrb,
932  const PinAtPort& ocrb_out,
933  const PinAtPort& ocrb_outinv);
935 
937  int Step(bool &untilCoreStepFinished, SystemClockOffset *nextStepIn_ns);
939  void Reset();
941  unsigned int CpuCycle();
942 };
943 
944 #endif
TraceValue * counterTrace
TraceValue instance for counter itself.
Definition: hwtimer.h:784
COMtype
types of compare match output modes
Definition: hwtimer.h:115
TimerEventListener * eventListener
event listener for timer events
Definition: hwtimer.h:56
int cfg_com_b
internal (async) setting for compare output modul B
Definition: hwtimer.h:824
unsigned char operator=(unsigned char v)
assign new register value
Definition: hwtimer.h:758
~BasicTimerUnit()
Definition: hwtimer.h:77
unsigned char Get_OCRAH()
Register access to read output compare register A high byte.
Definition: hwtimer.h:276
bool WGMisPWM(void)
returns true, if WGM is in one of the PWM modes
Definition: hwtimer.h:183
unsigned char Get_TCCRA()
Register access to read control register A.
Definition: hwtimer.h:544
Basic AVR device, contains the core functionality.
Definition: avrdevice.h:66
unsigned long vlast_tcnt
timercounter BEFORE count operation
Definition: hwtimer.h:136
bool asyncClock_plllock
pll frequency is locked
Definition: hwtimer.h:837
void MaskOutSync(unsigned char mask)
Mask out a value inside sync area and do not force a change event.
Definition: hwtimer.h:772
int asyncClock_step
step counter for step delays. -1, if not in async mode
Definition: hwtimer.h:833
bool tocrb_internal_flag
OCFxB flag is set, have to be delayed by 1 CK.
Definition: hwtimer.h:810
int icapNCcounter
counter for input capture noise canceler
Definition: hwtimer.h:54
IOSpecialReg * gtccrRegister
instance of GTCCR register
Definition: hwtimer.h:842
unsigned long counter
THE timer counter.
Definition: hwtimer.h:789
unsigned char dtprescaler
dead time prescaler counter
Definition: hwtimer.h:791
IOReg< HWTimer16 > ocrc_h_reg
output compare C register, high byte
Definition: hwtimer.h:316
int wgm_raw
this is the wgm raw value from register
Definition: hwtimer.h:419
int dtHigh
dead time raise delay
Definition: hwtimer.h:710
unsigned char inValue
input register value
Definition: hwtimer.h:748
unsigned char Get_OCRB()
Register access to read output compare register B.
Definition: hwtimer.h:869
compare[0] value reached for one count cycle
Definition: hwtimer.h:64
int cfg_com_a
internal (async) setting for compare output modul A
Definition: hwtimer.h:823
void SetDeadTime(int highTime, int lowTime)
Configure dead time counter.
Definition: hwtimer.h:736
void Set_OCRA(unsigned char val)
Register access to set output compare register A.
Definition: hwtimer.h:219
IRQLine * timerOCRBInt
irq line for output compare B interrupt
Definition: hwtimer.h:849
int dtLow
dead time fall delay
Definition: hwtimer.h:711
void Set_OCRB(unsigned char val)
Register access to set output compare register B.
Definition: hwtimer.h:867
unsigned char Get_TCCRB()
Register access to read control register B.
Definition: hwtimer.h:607
void Set_TCCR(unsigned char val)
Register access to set control register.
Definition: hwtimer.h:857
void WGMFunc_noop(CEtype event)
WGM noop function.
Definition: hwtimer.h:187
void Set_ICRL(unsigned char val)
Register access to set input capture register low byte.
Definition: hwtimer.h:305
unsigned char Get_TCNTL()
Register access to read counter register low byte.
Definition: hwtimer.h:271
~HWTimerTinyX5()
Definition: hwtimer.h:934
void Set_DTPS1(unsigned char val)
Register access to set dead time prescaler.
Definition: hwtimer.h:877
TraceValue * counterTrace
TraceValue instance for counter itself.
Definition: hwtimer.h:52
bool icapNCstate
state for input capture noise canceler
Definition: hwtimer.h:55
unsigned char tccrb_val
register value TCCRB
Definition: hwtimer.h:426
unsigned char Get_TCCRB()
Register access to read control register B.
Definition: hwtimer.h:549
unsigned char Get_OCRC()
Register access to read output compare register C.
Definition: hwtimer.h:874
IOReg< HWTimer8_1C > tccr_reg
control register
Definition: hwtimer.h:388
PinAtPort outPinInv
inverted output pin for OCR unit
Definition: hwtimer.h:705
HWTimerTinyX5_SyncReg tccr_inout_val
register value TCCR1
Definition: hwtimer.h:794
IOReg< HWTimer16 > ocra_h_reg
output compare A register, high byte
Definition: hwtimer.h:312
Timer unit with 8Bit counter and one output compare unit.
Definition: hwtimer.h:377
int cfg_mode
internal (async) timer mode setting
Definition: hwtimer.h:821
Extends BasicTimerUnit to provide common support to all types of 8Bit timer units.
Definition: hwtimer.h:202
unsigned char regValue
valid register value inside sync area
Definition: hwtimer.h:749
unsigned char Get_TCCR()
Register access to read control register.
Definition: hwtimer.h:385
unsigned long limit_top
TOP value for counting.
Definition: hwtimer.h:143
unsigned char tccra_val
register value TCCRA
Definition: hwtimer.h:538
unsigned char Get_OCRA()
Register access to read output compare register A.
Definition: hwtimer.h:864
IOReg< HWTimer16 > ocra_l_reg
output compare A register, low byte
Definition: hwtimer.h:313
IOReg< HWTimer8 > tcnt_reg
counter register
Definition: hwtimer.h:229
void Set_OCRBL(unsigned char val)
Register access to set output compare register B low byte.
Definition: hwtimer.h:287
bool WGMuseICR(void)
returns true, if WGM uses IC register for defining TOP counter value
Definition: hwtimer.h:185
HWTimerTinyX5_SyncReg ocrb_inout_val
register value OCRB
Definition: hwtimer.h:796
unsigned char Get_DT1B()
Register access to read dead time value for channel B.
Definition: hwtimer.h:889
IOReg< HWTimer16 > tcnt_h_reg
counter register, high byte
Definition: hwtimer.h:310
unsigned char ocra_internal_val
internal (async) register value for OCRA1
Definition: hwtimer.h:813
IOReg< HWTimer16 > ocrc_l_reg
output compare C register, low byte
Definition: hwtimer.h:317
unsigned char tccrb_val
register value TCCRB
Definition: hwtimer.h:660
unsigned char accessTempRegister
the high byte temporary register for read/write access to TCNT and ICR
Definition: hwtimer.h:250
index for OCR unit C
Definition: hwtimer.h:125
Represents a timer interrupt line, Frontend for timer interrupts.
Definition: timerirq.h:42
BOTTOM reached for one count cycle.
Definition: hwtimer.h:63
bool count_down
counter counts down, used for precise pwm modes
Definition: hwtimer.h:141
unsigned char tccra_val
register value TCCRA
Definition: hwtimer.h:479
unsigned long ocra_compare
active compare value for OCR A unit
Definition: hwtimer.h:814
unsigned long limit_bottom
BOTTOM value for up/down counting.
Definition: hwtimer.h:142
unsigned char tccrb_val
register value TCCRB
Definition: hwtimer.h:480
unsigned char tccr_val
register value TCCR
Definition: hwtimer.h:380
Interface class to connect hardware units to control registers.
Definition: rwmem.h:398
unsigned char Get_TCCRC()
Register access to read control register C.
Definition: hwtimer.h:612
IOSpecialReg * dt1aRegister
instance of DT1A register
Definition: hwtimer.h:845
unsigned char dtps1_inout_val
register value DTPS1
Definition: hwtimer.h:799
PinAtPort outPin
normal output pin for OCR unit
Definition: hwtimer.h:704
void Set_ICRH(unsigned char val)
Register access to set input capture register high byte.
Definition: hwtimer.h:301
IOReg< HWTimer16_2C3 > tccra_reg
control register A
Definition: hwtimer.h:615
unsigned char Get_TCNTH()
Register access to read counter register high byte.
Definition: hwtimer.h:267
unsigned char Get_OCRCH()
Register access to read output compare register C high byte.
Definition: hwtimer.h:294
IOReg< HWTimer8_2C > tccrb_reg
control register B
Definition: hwtimer.h:440
int cfg_prescaler
internal (async) prescaler setting
Definition: hwtimer.h:819
bool asyncClock_pll
pll is switched on
Definition: hwtimer.h:836
IOSpecialReg * dt1bRegister
instance of DT1B register
Definition: hwtimer.h:846
void Set_OCRC(unsigned char val)
Register access to set output compare register C.
Definition: hwtimer.h:872
PWM output unit for timer 1 on ATtiny25/45/85.
Definition: hwtimer.h:702
unsigned long prescaler
THE prescaler counter.
Definition: hwtimer.h:790
IOReg< HWTimer16_2C3 > tccrb_reg
control register B
Definition: hwtimer.h:616
bool ocrPWM
flag, if OCR unit is in PWM mode
Definition: hwtimer.h:708
void Set_OCRCH(unsigned char val)
Register access to set output compare register C high byte.
Definition: hwtimer.h:292
bool captureInputState
saved state for input capture
Definition: hwtimer.h:53
bool asyncClock_lsm
mode switch for lsm mode (32MHz clock)
Definition: hwtimer.h:835
an counter overflow occured
Definition: hwtimer.h:62
IOReg< HWTimer8_2C > tccra_reg
control register A
Definition: hwtimer.h:439
Basic timer unit.
Definition: hwtimer.h:48
IOReg< HWTimer16 > icr_h_reg
input capture register, high byte
Definition: hwtimer.h:318
TraceValue * dTPrescalerTrace
TraceValue instance for dead time prescaler.
Definition: hwtimer.h:786
TimerTinyX5_OCR ocra_unit
OCR control unit for OCR channel A.
Definition: hwtimer.h:815
PrescalerMultiplexer * premx
prescaler multiplexer
Definition: hwtimer.h:131
Timer unit with 16Bit counter and 2 output compare units, but 3 config registers. ...
Definition: hwtimer.h:593
unsigned char Get_OCRB()
Register access to read output compare register B.
Definition: hwtimer.h:226
index for OCR unit B
Definition: hwtimer.h:124
IRQLine * timerOCRAInt
irq line for output compare A interrupt
Definition: hwtimer.h:848
Build a register for TraceValue&#39;s.
Definition: traceval.h:442
unsigned char Get_TCNT()
Register access to read counter register high byte.
Definition: hwtimer.h:216
void SetACIC(bool acic)
reflect ACIC flag to input capture source
Definition: hwtimer.h:88
unsigned char tccrb_val
register value TCCRB
Definition: hwtimer.h:597
compare[1] value reached for one count cycle
Definition: hwtimer.h:65
Helper class to simulate transfer of register values from bus area to timer async area...
Definition: hwtimer.h:746
IOReg< HWTimer16 > icr_l_reg
input capture register, low byte
Definition: hwtimer.h:319
timer unit for timer 1 on ATtiny25/45/85
Definition: hwtimer.h:778
unsigned char tcnt_in_val
input register value for TCNT
Definition: hwtimer.h:806
unsigned char tcnt_out_val
output register value for TCNT
Definition: hwtimer.h:804
IOReg< HWTimerTinyX5 > tccr_reg
control register
Definition: hwtimer.h:915
unsigned char Get_TCCRA()
Register access to read control register.
Definition: hwtimer.h:431
void Set_TCNTH(unsigned char val)
Register access to set counter register high byte.
Definition: hwtimer.h:265
Timer unit with 16Bit counter and 2 output compare units and 2 config registers.
Definition: hwtimer.h:528
int cs
select value for prescaler multiplexer
Definition: hwtimer.h:51
HWTimerTinyX5_SyncReg dt1a_inout_val
register value DT1A
Definition: hwtimer.h:800
unsigned char Get_TCCR()
Register access to read control register.
Definition: hwtimer.h:859
void Set_TCNT(unsigned char val)
Register access to set counter register high byte.
Definition: hwtimer.h:214
unsigned char GetBusValue(void)
read register value on input area
Definition: hwtimer.h:766
bool icapRisingEdge
Input capture on rising edge.
Definition: hwtimer.h:148
void Set_TCNT(unsigned char val)
Register access to set counter register.
Definition: hwtimer.h:852
void TimerEvent(bool isCompareEvent)
OCR event.
Definition: hwtimer.h:730
TimerTinyX5_OCR ocrb_unit
OCR control unit for OCR channel B.
Definition: hwtimer.h:818
unsigned char Get_ICRL()
Register access to read input capture register low byte.
Definition: hwtimer.h:307
unsigned char Get_DTPS1()
Register access to read dead time prescaler.
Definition: hwtimer.h:879
unsigned char Get_ICRH()
Register access to read input capture register high byte.
Definition: hwtimer.h:303
unsigned char Get_OCRCL()
Register access to read output compare register C low byte.
Definition: hwtimer.h:298
IOReg< HWTimer16_3C > tccra_reg
control register A
Definition: hwtimer.h:678
bool icapNoiseCanceler
Noise canceler for input capturing enabled.
Definition: hwtimer.h:149
IOReg< HWTimer16 > tcnt_l_reg
counter register, low byte
Definition: hwtimer.h:311
unsigned char Get_OCRBL()
Register access to read output compare register B low byte.
Definition: hwtimer.h:289
unsigned char Get_TCCRA()
Register access to read control register A.
Definition: hwtimer.h:665
unsigned char tccr_val
register value TCCR
Definition: hwtimer.h:350
void Set_DT1B(unsigned char val)
Register access to set dead time value for channel B.
Definition: hwtimer.h:887
long long SystemClockOffset
unsigned char Get_TCCR()
Register access to read control register.
Definition: hwtimer.h:355
bool tocra_internal_flag
OCFxA flag is set, have to be delayed by 1 CK.
Definition: hwtimer.h:809
TraceValue * prescalerTrace
TraceValue instance for prescaler.
Definition: hwtimer.h:785
bool ClockAndChanged(void)
check after one clock, if register value has changed
Definition: hwtimer.h:769
HWTimerTinyX5_SyncReg dt1b_inout_val
register value DT1B
Definition: hwtimer.h:801
unsigned char Get_TCNT()
Register access to read counter register.
Definition: hwtimer.h:854
IOReg< HWTimer16_3C > tccrc_reg
control register C
Definition: hwtimer.h:680
IOReg< HWTimer16_1C > tccrb_reg
control register B
Definition: hwtimer.h:494
unsigned char Get_DT1A()
Register access to read dead time value for channel A.
Definition: hwtimer.h:884
IOReg< HWTimer16 > ocrb_l_reg
output compare B register, low byte
Definition: hwtimer.h:315
int ocrComMode
COM mode.
Definition: hwtimer.h:707
WGMtype
types of waveform generation modes
Definition: hwtimer.h:95
compare[2] value reached for one count cycle
Definition: hwtimer.h:66
Timer unit with 16Bit counter and 3 output compare units.
Definition: hwtimer.h:656
HWTimerTinyX5_SyncReg ocra_inout_val
register value OCRA
Definition: hwtimer.h:795
unsigned long icapRegister
Input capture register.
Definition: hwtimer.h:146
unsigned long limit_max
MAX value for counting.
Definition: hwtimer.h:144
int wgm_raw
this is the wgm raw value from register
Definition: hwtimer.h:531
void Set_OCRAH(unsigned char val)
Register access to set output compare register A high byte.
Definition: hwtimer.h:274
unsigned char ocrb_internal_val
internal (async) register value for OCRB1
Definition: hwtimer.h:816
virtual void fireEvent(int event)=0
IOReg< HWTimerTinyX5 > tcnt_reg
counter register
Definition: hwtimer.h:916
AvrDevice * core
pointer to device core
Definition: hwtimer.h:130
unsigned char tccra_val
register value TCCRA
Definition: hwtimer.h:425
unsigned char Get_TCCRB()
Register access to read control register.
Definition: hwtimer.h:436
int updown_counting
count direction control flag, true, if up/down counting
Definition: hwtimer.h:140
unsigned char Get_OCRA()
Register access to read output compare register A.
Definition: hwtimer.h:221
Timer unit with 16Bit counter and one output compare unit.
Definition: hwtimer.h:470
HWTimerTinyX5_SyncReg ocrc_inout_val
register value OCRC
Definition: hwtimer.h:797
IRQLine * timerOverflow
irq line for overflow interrupt
Definition: hwtimer.h:132
IOReg< HWTimer16_1C > tccra_reg
control register A
Definition: hwtimer.h:493
unsigned long vtcnt
THE timercounter.
Definition: hwtimer.h:135
Timer unit with 8Bit counter and no output compare unit.
Definition: hwtimer.h:347
IOReg< HWTimerTinyX5 > tocrc_reg
OCR register channel C.
Definition: hwtimer.h:919
void Set_TCNTL(unsigned char val)
Register access to set counter register low byte.
Definition: hwtimer.h:269
IOReg< HWTimerTinyX5 > dt1b_reg
dead time generator register channel B
Definition: hwtimer.h:922
IOReg< HWTimerTinyX5 > dtps1_reg
dead time generator prescaler register
Definition: hwtimer.h:920
IOReg< HWTimer8_0C > tccr_reg
control register
Definition: hwtimer.h:358
bool ocrOut
OCR status before dead time generator.
Definition: hwtimer.h:709
IOReg< HWTimer16 > ocrb_h_reg
output compare B register, high byte
Definition: hwtimer.h:314
int wgm_raw
this is the wgm raw value from register
Definition: hwtimer.h:473
void ForceEvent()
Manual change of OCR unit by force bit.
Definition: hwtimer.h:733
int cfg_dtprescaler
internal (async) dead time prescaler setting
Definition: hwtimer.h:820
void Reset(unsigned char v)
perform a reset to set valid reset values without clock
Definition: hwtimer.h:755
IOReg< HWTimer16_2C3 > tccrc_reg
control register C
Definition: hwtimer.h:617
PrescalerMultiplexer without external count pin.
Definition: prescalermux.h:35
void Set_DT1A(unsigned char val)
Register access to set dead time value for channel A.
Definition: hwtimer.h:882
bool at8515_mode
signals, that this timer units is used in AT90S8515
Definition: hwtimer.h:532
IOReg< HWTimer8 > ocra_reg
output compare A register
Definition: hwtimer.h:230
unsigned char tccra_val
register value TCCRA
Definition: hwtimer.h:659
void Set_OCRA(unsigned char val)
Register access to set output compare register A.
Definition: hwtimer.h:862
IOReg< HWTimerTinyX5 > tocra_reg
OCR register channel A.
Definition: hwtimer.h:917
unsigned char tccrb_val
register value TCCRB
Definition: hwtimer.h:539
unsigned char Get_TCCRC()
Register access to read control register C.
Definition: hwtimer.h:675
Class, which provides input capture source for 16bit timers.
Definition: icapturesrc.h:34
IOReg< HWTimer16_3C > tccrb_reg
control register B
Definition: hwtimer.h:679
IRQLine * timerCapture
irq line for capture interrupt
Definition: hwtimer.h:133
bool tcnt_set_flag
flag to signal, that a new counter value was set
Definition: hwtimer.h:807
int dtCounter
dead time counter
Definition: hwtimer.h:712
unsigned char Get_TCCRA()
Register access to read control register A.
Definition: hwtimer.h:485
unsigned char tccra_val
register value TCCRA
Definition: hwtimer.h:596
Timer unit with 8Bit counter and 2 output compare unit.
Definition: hwtimer.h:416
ICaptureSource * icapSource
Input capture source.
Definition: hwtimer.h:147
virtual ~TimerEventListener()
Definition: hwtimer.h:41
unsigned char Get_TCCRB()
Register access to read control register B.
Definition: hwtimer.h:490
unsigned char Get_TCCRA()
Register access to read control register A.
Definition: hwtimer.h:602
CEtype
event types for timer/counter
Definition: hwtimer.h:60
IOReg< HWTimer16_2C2 > tccrb_reg
control register B
Definition: hwtimer.h:553
void SetTimerEventListener(TimerEventListener *listener)
Set event listener.
Definition: hwtimer.h:91
unsigned long ocrb_compare
active compare value for OCR B unit
Definition: hwtimer.h:817
IOReg< HWTimerTinyX5 > dt1a_reg
dead time generator register channel A
Definition: hwtimer.h:921
bool cfg_ctc
internal (async) flag for clear timer counter
Definition: hwtimer.h:822
void Set_OCRAL(unsigned char val)
Register access to set output compare register A low byte.
Definition: hwtimer.h:278
Extends BasicTimerUnit to provide common support to all types of 16Bit timer units.
Definition: hwtimer.h:246
SystemClockOffset asyncClock_locktime
time, when pll is locked
Definition: hwtimer.h:838
IOReg< HWTimerTinyX5 > tocrb_reg
OCR register channel B.
Definition: hwtimer.h:918
bool tov_internal_flag
TOV flag is set, have to be delayed by 1 CK.
Definition: hwtimer.h:808
IOReg< HWTimer8 > ocrb_reg
output compare B register
Definition: hwtimer.h:231
IOSpecialReg * dtps1Register
instance of DTPS1 register
Definition: hwtimer.h:844
unsigned char Get_TCCRB()
Register access to read control register B.
Definition: hwtimer.h:670
void Set_OCRCL(unsigned char val)
Register access to set output compare register C low byte.
Definition: hwtimer.h:296
HWTimerTinyX5_SyncReg gtccr_in_val
input register value GTCCR
Definition: hwtimer.h:798
OCRIDXtype
indices for OC units
Definition: hwtimer.h:122
unsigned char tcnt_out_async_tmp
temporary register value for TCNT in async mode
Definition: hwtimer.h:805
IOSpecialReg * pllcsrRegister
instance of PLLCSR register
Definition: hwtimer.h:843
Analog comparator peripheral.
Definition: hwacomp.h:42
unsigned char Get_OCRAL()
Register access to read output compare register A low byte.
Definition: hwtimer.h:280
IRQLine * timerOverflowInt
irq line for overflow interrupt
Definition: hwtimer.h:847
AvrDevice * core
pointer to device core
Definition: hwtimer.h:841
unsigned char Get_OCRBH()
Register access to read output compare register B high byte.
Definition: hwtimer.h:285
void Set_OCRBH(unsigned char val)
Register access to set output compare register B high byte.
Definition: hwtimer.h:283
IOReg< HWTimer16_2C2 > tccra_reg
control register A
Definition: hwtimer.h:552
WGMtype wgm
waveform generation mode
Definition: hwtimer.h:151
bool asyncClock_async
mode switch for async mode
Definition: hwtimer.h:834
void Set_OCRB(unsigned char val)
Register access to set output compare register B.
Definition: hwtimer.h:224