Introduction
Since timer interrupt runs in background of microcontroller program. We can use this feature to create timing tick activating some tasks.
Multiplexing a display requires an activating time ranging around 5ms for each digit to display properly. More digits require more time in milliseconds. Other remaining tasks in microcontroller program need to wait until display driving finished. Embedded controller program designed using this method is not responsive.
Using timer0 interrupt, a timing tick can activate each digit of multiplexing display regularly. Display timing doesn't consume main program loop timing. Main program just operate other remaining tasks. Any program written using interrupt is flexible.
Simulation sample of this program |
Timer0 Interrupt Programming
This example program multiplex a two-digit display using timer0 interrupt timing ticks. Each digit will be activated for 5ms. It's a free running timer that counts up from 0 to 59 seconds before it resets.
Timer0 clock prescaler is assigned to 1:256. Number of ticks per second is 30. Display type is common cathode. We just use an inverting buffer here due to simulation problem.
Schematic Diagram |
This controller pulse from its 8MHz internal oscillator.
Click here to download its source file.
No comments:
Post a Comment