Menu

#37 Missing WGM2 and WGM3 in AVR.Timer1.Init_CTC  Edit

v1.2.2
open
nobody
None
1
2021-03-18
2021-03-18
Anonymous
No

Missing WGM2 and WGM3 in AVR.Timer1.Init_CTC.

Following works on ATmega1284:

   procedure Init_CTC (Prescaler : Scale_Type; Overflow : Unsigned_16 := 0)
   is
   begin
      --  set the control register with the prescaler and mode flags to
      --  timer output compare mode and clear timer on compare match
      Ctrl_Reg := (MCU.COM1A0_Bit => False, --  \  normal operation,
                   MCU.COM1A1_Bit => False, --  /  OC1A disconnected

                   MCU.COM1B0_Bit => False, --  \  normal operation,
                   MCU.COM1B1_Bit => False, --  /  OC1B disconnected

                   MCU.WGM10_Bit => False,  --  \  Clear Timer on Compare
                   MCU.WGM11_Bit => False,  --  /  Match (CTC) / Low Part

                   others    => False);

      WGM2 := True;                         --  \  Clear Timer on Compare
      WGM3 := False;                        --  /  Match (CTC) / High Part

      Init_Common (Prescaler);

      --  enable Timer1 output compare interrupt
      Output_Compare_Interrupt_Enable := True;

      Output_Compare_Reg := Overflow;
   end Init_CTC;

Discussion

Anonymous
Anonymous

Add attachments
Cancel