Advanced PIC Microcontroller Projects in C: From USB to RTOS with the PIC18F Series

Project 6.7: Two-Digit Multiplexed 7-Segment LED Counter with Timer Interrupt

Project 6.7: Two-Digit Multiplexed 7-Segment LED Counter with Timer Interrupt

Project Description

This project is similar to Project 6 but here the microcontroller's timer interrupt is used to refresh the displays. In Project 6 the microcontroller was busy updating the displays every 10ms and could not perform any other tasks. For example, the program given in Project 6 cannot be used to make a counter with a one-second delay between counts, as the displays cannot be updated while the program waits for one second.

In this project a counter is designed to count from 0 to 99, and the display is refreshed every 5ms inside the timer interrupt service routine. The main program can then perform other tasks, in this example incrementing the count and waiting for one second between counts.

In this project Timer 0 is operated in 8-bit mode. The time for an interrupt is given by:

where Prescaler is the selected prescaler value, and TMR0L is the value loaded into timer register TMR0L to generate timer interrupts every Time period.

In our application the clock frequency is 4MHz, that is, clock period = 0.25 ?s, and Time = 5ms. Selecting a prescaler value of 32, the number to be loaded into TMR0L can be calculated as follows:

or

Thus, TMR0L should be loaded with 100. The value to be loaded into TMR0 control register T0CON can then be found as:

Thus, T0CON register should be loaded with hexadecimal 0 C4. The next register to be configured is...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Counter and Timer Boards
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.