1 / 22

University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering

University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering. Microcontroller Lab. 2:. Interrupts and Timers/Counters. In this session. Review the previous session. We will determine on 7-segmnts display and How to interface it using microcontroller.

tim
Download Presentation

University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering

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. University Of Khartoum Faculty Of Engineering Electrical and Electronic Engineering Microcontroller Lab. 2: Interrupts and Timers/Counters

  2. In this session • Review the previous session. • We will determine on 7-segmnts display and How to interface it using microcontroller. • How to make external interrupt. • How to use timers and counters.

  3. Review • There are three registers associated with each port, name them and clarify their functions !! • How can we control switching high level-voltage devices like motors?

  4. 7-segments Display • A seven-segment display, or seven-segment indicator, is a form of electronic display device for displaying decimal numerals. • As its name indicates, is composed of seven elements individually on or off, they can be combined to produce simplified representations of the numerals.

  5. 7-segments Display • They are widely used in digital clocks, electronic meters, and other electronic devices for displaying numerical information.

  6. 7-segments Display

  7. Interfacing 7-segment Display with MCU

  8. Interfacing with MCU using decoder

  9. Multiplexing 7-segments Display with MCU

  10. 7-segments Display • Basically there are two types of 7-Seg display's: • Common Cathode where all the segments share the same Cathode. • Common Anode where all Segments share the same Anode.

  11. Interrupt Subsystem • A microcontroller normally executes instructions in an orderly fetch-decode-executesequence as dictated by a user-written program. • To enable the microcontroller to handle unscheduled, higher-priority events that might occur inside or outside the microcontroller, it must be equipped to interrupt subsystem.

  12. Interrupt Subsystem • The external interrupts INT0, INT1, and INT2 trigger an interrupt within the ATmega32 when an external event of user-specified characteristics occurs at the pin associated with the specific interrupt. • The internal interrupts support the efficient operation of peripheral subsystems aboard the microcontroller.

  13. Interrupt Subsystem

  14. Interrupt Subsystem • The external interrupts can be triggered by a falling or • rising edge or a low level. • Observe that, if enabled, the interrupts will trigger even if the INT0..2 pins are configured as outputs. This feature provides a way of generating a software interrupt.

  15. Timer/Counter Subsystem • The Atmega 32 is packed with three timers for timing functionality as follows; • Two 8-Bit Timers (timer/counter0, timer/counter2) • One 16-bit timer (timer/counter1). • The number actually refers to the resolution of the timer/counter unit.

  16. Timer/Counter Subsystem • Timer/Counter Register – TCNTn: • Is a 8/16-bits register have a feature of increment/ decrement its value according to clock with certain frequency ( works as Timer) or through output signal (works as Counter). • Output Compare Register OCRn: • Contains an 8/16-bits value that is continuously compared with the counter value (TCNTn). A match can be used to generate an output compare interrupt, or to generate a waveform output on the OC0 pin.

  17. Clock Source • The Timer/Counter can be clocked internally, via the presaler, or by an external clock source on the Tn pin.

  18. Prescalers

  19. Timer/Counter Subsystem • When reaching max value; an overflow interrupt may be initiated, this interrupt is an internal interrupt in contrast to the second type of interrupts; external interrupt. • When issued, an interrupt service routine is initiated, Interrupt Service Routines (ISR) are functions that are executed in response to a hardware event rather than a function call embedded in the program. • Adjusting the overflow interrupt allows us to determine the function we want the MCU to perform upon timer/counter reaching max value.

  20. Modes of operations • Normal Mode: • In this mode the counting direction is always up (incrementing), and no counter clear is performed. The counter simply overruns when it passes its maximum 8-bit value (TOP = 0xFF) and then restarts from the bottom (0x00). The output compare unit can be used to generate interrupts at some given time. • Clear Timer on Compare Match (CTC) Mode: • In CTC mode the counter is cleared to zero when the counter value (TCNTn) matches the OCRn.

  21. Modes of operations • For generating a waveform output in CTC mode, the OC0 output can be set to toggle its logical level on each compare match by setting the Compare Output mode bits to toggle mode

  22. Any Questions

More Related