04EI General Purpose Timer (GPT) Unit • • 27.9.2009 The GPT unit represents a very flexible multifunctional timer/counter structure which may be used for many different time related tasks such as event timing and counting, pulse width and duty cycle measurements, pulse generation, or pulse multiplication. The GPT unit incorporates three 16-bit timers. Each timer may operate independently in a number of different modes, or may be concatenated with another timer. • Each of the three timers T2, T3, T4 of module GPT1 can be configured individually for one of four basic modes of operation, which are Timer, Gated Timer and Counter Mode. In Timer Mode, the input clock for a timer is derived from the CPU clock, divided by a programmable prescaler, while Counter Mode allows a timer to be clocked in reference to external events. • Pulse width or duty cycle measurement is supported in Gated Timer Mode, where the operation of a timer is controlled by the ‘gate’ level on an external input pin. For these purposes, each timer has one associated port pin (TxIN) which serves as gate or clock input. The maximum resolution of the timers in module GPT1 is 0.4µs (at 20 MHZ). • The count direction (up/down) for each timer is programmable by software or may additionally be altered dynamically by an external signal on a port pin (TxEUD) to facilitate e.g. position tracking. • Timer T3 has an output toggle latch (T3OTL) which changes its state on each timer over-flow/underflow. The state of this latch may be used internally to clock timers T2 and T4 for measuring long time periods with high resolution. • In addition to their basic operating modes, timers T2 and T4 may be configured as reload or capture registers for timer T3. When used as capture or reload registers, timers T2 and T4 are stopped. The contents of timer T3 is captured into T2 or T4 in response to a signal at their associated input pins (TxIN). Timer T3 is reloaded with the contents of T2 or T4 triggered either by an external signal or by a selectable state transition of its toggle latch T3OTL. D µ Embedded Systems Page 4
Watchdog Timer-Interrupt Function The Watchdog Timer (WDT) uses two bits in the SFRs for interrupt control. The WDT interrupt flag (WDTIFG) (located in IFG1.0, initial state is reset) The WDT interrupt enable (WDTIE) (located in IE1.0, initial state is reset) When using the watchdog mode, the WDTIFG flag is used by the reset interrupt service routine to determine if the watchdog caused the device to reset. If the flag is set, then the Watchdog Timer initiated the reset condition (either by timing out or by a security key violation). If the flag is cleared, then the PUC was caused by a different source. See chapter 3 for more details on the PUC and POR signals. When using the Watchdog Timer in interval-timer mode, the WDTIFG flag is set after the selected time interval and a watchdog interval-timer interrupt is requested. The interrupt vector address in interval-timer mode is different from that in watchdog mode. In interval-timer mode, the WDTIFG flag is reset automatically when the interrupt is serviced. The WDTIE bit is used to enable or disable the interrupt from the Watchdog Timer when it is being used in interval-timer mode. Also, the GIE bit enables or disables the interrupt from the Watchdog Timer when it is being used in intervaltimer mode. CPE 323 8
Watchdog Timer-Interrupt Function The Watchdog Timer (WDT) uses two bits in the SFRs for interrupt control. The WDT interrupt flag (WDTIFG) (located in IFG1.0, initial state is reset) The WDT interrupt enable (WDTIE) (located in IE1.0, initial state is reset) When using the watchdog mode, the WDTIFG flag is used by the reset interrupt service routine to determine if the watchdog caused the device to reset. If the flag is set, then the Watchdog Timer initiated the reset condition (either by timing out or by a security key violation). If the flag is cleared, then the PUC was caused by a different source. See chapter 3 for more details on the PUC and POR signals. When using the Watchdog Timer in interval-timer mode, the WDTIFG flag is set after the selected time interval and a watchdog interval-timer interrupt is requested. The interrupt vector address in interval-timer mode is different from that in watchdog mode. In interval-timer mode, the WDTIFG flag is reset automatically when the interrupt is serviced. The WDTIE bit is used to enable or disable the interrupt from the Watchdog Timer when it is being used in interval-timer mode. Also, the GIE bit enables or disables the interrupt from the Watchdog Timer when it is being used in intervaltimer mode. CPE 323 16
GNU definition GNU = GNU not unix GNU = GNU not unix not unix GNU = GNU not unix not unix not unix GNU = GNU not unix not unix not unix not unix GNU = GNU not unix not unix not unix not unix not unix GNU = GNU (not unix) * (∞ + 1 ) Java Foundations, 3rd Edition, Lewis/DePasquale/Chase 5 - 10
Watchdog Timer General The primary function of the watchdog-timer module (WDT) is to perform a controlled-system restart after a software problem occurs. If the selected time interval expires, a system reset is generated. If the watchdog function is not needed in an application, the module can work as an interval timer, to generate an interrupt after the selected time interval. Features of the Watchdog Timer include: Eight software-selectable time intervals Two operating modes: as watchdog or interval timer Expiration of the time interval in watchdog mode, which generates a system reset; or in timer mode, which generates an interrupt request Safeguards which ensure that writing to the WDT control register is only possible using a password Support of ultralow-power using the hold mode Watchdog/Timer two functions: SW Watchdog Mode Interval Timer Mode CPE 323 3
Watchdog Timer General The primary function of the watchdog-timer module (WDT) is to perform a controlled-system restart after a software problem occurs. If the selected time interval expires, a system reset is generated. If the watchdog function is not needed in an application, the module can work as an interval timer, to generate an interrupt after the selected time interval. Features of the Watchdog Timer include: Eight software-selectable time intervals Two operating modes: as watchdog or interval timer Expiration of the time interval in watchdog mode, which generates a system reset; or in timer mode, which generates an interrupt request Safeguards which ensure that writing to the WDT control register is only possible using a password Support of ultralow-power using the hold mode Watchdog/Timer two functions: SW Watchdog Mode Interval Timer Mode CPE 323 11
Programmable Part Types Semiconductor manufacturers have developed several types of regular programmable logic elements. Three important ones are: 1. Read Only Memory (ROM) -- a fixed array of AND gates and a programmable array of OR gates. 2. Programmable Array Logic (PAL) -- a programmable array of AND gates feeding a fixed array of OR gates. 3. Programmable Logic Array (PLA) -- a programmable array of AND gates feeding a programmable array of OR gates. All of the above use regular structures of logic elements that can be thought of as a "memory array". There are also programmable devices that look more like programmable logic cells with programmable interconnect. SYEN 3330 Digital Systems Chapter 4-2 Page 4
04EI General Purpose Timer 1 (GPT 1 - 20 MHz) • • • • • 27.9.2009 Drei 16-Bit Vor-/Rückwärts-Zähler: 1 Core Timer(T3) und 2 Auxiliary Timers (T2,T4) Takteingangssignale: – Timer Modus: Interner Takteingang mit Vorteiler bis zu 2.5 MHz / 400 ns; der Takt kann mit einem externen Signal verknüpft werden. – Counter Modus: Externer Takt bis zu 1.25 MHz. – Kaskadieren des Core-Timer mit jedem der Aux.-Timer (33-Bit timer). – Zählrichtung kann mittels Eingangssignal gewechselt werden. Ausgangssignale – Interrupt-Generierung und Signalwechsel durch den Core Timer T3. – Interrupt-Generierung durch die Auxiliary Timer T2 und T4. Reload: Der Core Timer kann mit dem Inhalt eines beliebigen Auxiliary Timer geladen werden. Capture: Der Inhalt des Core Timer kann in jeden der Auxiliary Timer übernommen werden. D µ Embedded Systems Seite 4
04EI GPT 1 Summary (GPT 1 - 20 MHz) 12.08.2013 • Three 16-Bit up/down-counter: 1 Core Timer(T3) and 2 Auxiliary Timers (T2,T4) • Clock input signals: – Timer Modus: Internal clock input with prescaler up to 2.5 MHz / 400 ns; – Counter Modus: External clock up to 1.25 MHz. – Cascading of the Core-Timer with each of the Aux.-Timer (33-Bit timer). – Counting direction can be changed via input signal. • Output signals – Interrupt-generation and signal switching via Core Timer T3. – Interrupt-generation via Auxiliary Timer T2 and T4. • Reload: The Core Timer can be loaded with the content of any Auxiliary Timer. • Capture: The content of the Core Timer can be taken over to any Auxiliary Timer D µ Embedded Systems Page 5
The ‘ioctl.c’ module • These techniques are demonstrated in this device-driver module’s ‘ioctl()’ function • Two IOCTL commands are implemented – #define CURSOR_HIDE – #define CURSOR_SHOW 0 1 • Applications can open the device-file, then use an ioctl-command; for example: int fd = open( “/dev/vram”, O_RDWR ); ioctl( fd, CURSOR_HIDE);
Watchdog Timer-Timer Mode Setting WDTCTL register bit TMSEL to 1 selects the timer mode. This mode provides periodic interrupts at the selected time interval. A time interval can also be initiated by writing a 1 to bit CNTCL in the WDTCTL register. When the WDT is configured to operate in timer mode, the WDTIFG flag is set after the selected time interval, and it requests a standard interrupt service. The WDT interrupt flag is a single-source interrupt flag and is automatically reset when it is serviced. The enable bit remains unchanged. In interval-timer mode, the WDT interrupt-enable bit and the GIE bit must be set to allow the WDT to request an interrupt. The interrupt vector address in timer mode is different from that in watchdog mode. CPE 323 9
Watchdog Timer-Timer Mode Setting WDTCTL register bit TMSEL to 1 selects the timer mode. This mode provides periodic interrupts at the selected time interval. A time interval can also be initiated by writing a 1 to bit CNTCL in the WDTCTL register. When the WDT is configured to operate in timer mode, the WDTIFG flag is set after the selected time interval, and it requests a standard interrupt service. The WDT interrupt flag is a single-source interrupt flag and is automatically reset when it is serviced. The enable bit remains unchanged. In interval-timer mode, the WDT interrupt-enable bit and the GIE bit must be set to allow the WDT to request an interrupt. The interrupt vector address in timer mode is different from that in watchdog mode. CPE 323 17