![]() If the clkTC1 would turn out with a fractional value, we would go for another division factor and continue so until the clkTC1 would be an integer value. (2) We take (arbitrarily) division factor 1/1024 for the TC1 Clock Prescaler. This requires that the T1 must count n-number of clock pulses in 1-sec and then triggers the roll-over event. (1) We need to make an arrangement so that the TOV1 flag assumes Logic-H state at every 1-sec interval. The MCU goes to the interrupt subroutine (ISR) at location 001Ah, performs the assigned tasks and then goes back to the mainline program (the interrupted program).ĥ.2 Programming of Timer-1(T1) of ATmega328 to Generate 1-sec Time Delayįigure-5.2: Circuit for the demonstration of 1-sec time delay using Timer-1(T1) When the switches I (Global Interrupt Enable Bit of SREG-Register) and TOIE1 (T1 Overflow Interrupt Enable) of Fig-5.1 are kept in closed conditions, the MCU is automatically interrupted by the roll-over event. (11) There is also another way of knowing the arrival of the roll-over event, and it is the interrupt method. This feature can be very well utilized to generate varying time delay functions. By changing the value of the pre-set parameter, we can vary the arrival timing of the roll-over event. When the TC1 is started, it begins counting from the pres-set value. (10) The TC1 could be loaded with a known pre-set value. The user program may continuously poll this bit to know the exact time of the occurrence of a roll-over event. (9) Whenever a roll-over (overflow) occurs, the TOV1 (T1 Overflow Flag) of the MCU assumes LH-state. This event is known as roll-over event or overflow event. At the arrival of the next pulse, the TC1 rolls-over from all 1s to all 0s. In this mode, the TC1 works as an up-counter it begins counting from all 0s (0000h) and reaches at the full count of all 1s (FFFFh). The configuration as shown in Fig-5.1 depicts the normal mode of operation of TCNT1. ![]() In the C1 mode of operation, there is no division factor but, an option is available as to which edge (rising/falling) of the incoming pulse is to sense. (7) When the TC1 is configured to receive clocking (driving) pulses form the external source via Pin-11 (T1), we say that the TC1 is operating as C1 (Counter-1). (6) When the TC1 is configured to receive clocking (driving) pulses form the internal oscillator, we say that the TC1 is operating as T1 (Timer-1). The ‘TC1 Clock Prescaler’ division factor can also be changed using program codes. In Arduino UNO, the ‘System Clock Prescaler’ is programmed to pass 16 MHz however, the division factor can be changed through program codes. (5) When using the internal oscillator, the clkTC1 can be as low as 152.587890625 Hz, and it can be as high as 16 MHz. It has two sources: the internal oscillator and the external pulses. (4) The clocking pulse for the TCNT1 is named as clkTC1. The lower 8-bit register is known as TCNT1L, and the upper 8-bit register is known as TCNT1H. (3) The TC1 (TCNT1) is a 16-bit register, and it is composed of two 8-bit registers. Figure-5.1: Conceptual view for the TC1 resources of the ATmega328 Microcontroller
0 Comments
Leave a Reply. |