1 / 17

Programmable Timer

Programmable Timer. Mohamad KHALIL. clock ( external or internal). 16 bit counter. control circuit. Programmable Timer. The basic unit – counter (up or down) a clock source generate timing events (interrupts or timer output) if overflow or reach 0 if match with a preset value

Télécharger la présentation

Programmable Timer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programmable Timer Mohamad KHALIL

  2. clock ( external or internal) 16 bit counter control circuit Programmable Timer • The basic unit – counter (up or down) • a clock source • generate timing events (interrupts or timer output) • if overflow or reach 0 • if match with a preset value • measure time – read counter values • free running, reset or reload, compare

  3. interrupt 0? 16 bit counter E clock (2MHz) load counter register (499) Real-time Clock • Typical approach – • hardware unit generates an interrupt per unit of time (millisecond) • software counter (in memory) – increment when interrupted • assume E clock is 2MHz (0.5x103 ms) • set a counter to 499 and count down with E clock • when reach 0 – • interrupt • reload the counter with 499

  4. 5 4 3 2 1 0 6 5 4 3 2 1 0 6 5 Waveform Generator • Instead of interrupt, using the pulse to generate a square wave • To generate a square wave of 96KHz, what value should be loaded into the counter?

  5. Wave Generator (continued) • Variable duty cycle • need one more counter • application to digital-to-analog conversion • Single shot • Gated clock signal • Counter reset • reset signal • read and write operations

  6. clock 16 bit counter load event interrupt or ready flag edge detection input capture register Measurement • Input-capture : identify the moment that an event occurs • latch the counter value when triggered • CPU can read the value later • Output compare : control the timing of output bit • CPU set a value in output compare register • comparison with counter every clock cycle • if equal, send an output signal • external event counting • measuring elapsed time, pulse width, frequency, and period

  7. MC 6840 Programmable Timer Module

  8. Timer

  9. MC 6840 Programmable Timer Module • 3 16-bit counters • receive initial value from latch • halt or recycle • 3 16-bit data latches, comparison, and enable circuit • Register selection

  10. MC 6840 Control Register

  11. Initialization • Reset: hardware or CR1-bit 0 • Counter latch initialization – • write to MSB and then LSB • Counter initialization – transfer data from latch to counter, clear flag and interrupt • when reset, write to latch, or negative transition of G • Operating modes

  12. Continuous Wave Synthesis • Counter initialized, and enabled by RESET and G • Count down every clock cycle (starting from negative edge) • E clock • external clock (clocked in by E clock) • Square wave (16-bit counter) or variable duty cycle (8-bit M ad L counters)

  13. Example Waveform

  14. (N+1)*E_cycle (N+1)*E_cycle 1 9600*16 Clock for ACIA • 9600 baud rate and divided by 16 in ACIA (N+1) * E_cycle *2 = 1 / (9600*16) N = 1 + E_frequency / (9600*16*2)

  15. start counting stop counting Wave Measurement in 6840 • Pulse width comparison • Timeout period defined by counter initialization and clock period • If timeout period is longer than the pulse width, counter is disabled and interrupt flag set • read counter value to know the width

  16. Status register • Status

  17. Initialization • PTM initialization • To initialize the PTM, two steps are to be followed: • Store in the LATCHES the preset values. • Store in the control registers the suitable control words. • Note: the LATCHES are by default loaded by $FFFF if they are not initialized by the preset values. The data transfer from the LATCHES to the counters occurs when the counters are initialized. • The initialization of counters is done: • By activating the RESET input. • By setting to one CR10. • By initializing the LATCHES by the preset values. • By applying a negative edge transition at the Gate input.

More Related