Question

The Timer 0 module of a 16F873A is to be used to generate a regular interrupt....

The Timer 0 module of a 16F873A is to be used to generate a regular interrupt. The interrupt must occur every 5 ms. Crystal oscillators are available at the following frequencies: 1.0 MHz, 1.8432 MHz, 2.0 MHz, 2.457 MHz, 3.276 MHz, 3.579 MHz and 4.0 MHz. Recommend one crystal, and indicate how the Option register should be set in order to achieve this objective

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

For generating an interrupt every 5ms we should choose 3.276MHz crystal (actually 3.2768 MHz is better)

Now some explanation:

Recall the block diagram of Timer 0 of PIC16F873 from its datasheet. The signals relevant to solving this question are circled in red.

( A note to Chegg quality admin: Please note that using diagrams from semiconductor datasheet for educational purposes is not considered plagiarism. It is encouraged by the manufacturers actually. Thanks!)

To generate an interrupt every 5ms (i.e. at 200Hz), we need to input a clock signal to timer 0 which is integral multiple of 200Hz.

In this case if we select Fosc (the crystal frequency) 3.276 MHz, then CLKOUT = 0.819MHz

Then we set option bit T0CS to 0 so that CLKOUT signals is selected by the multiplexer and it reaches the prescalar.

We also set option bit PSA bit to 0 so that prescalar is assigned to timer 0 and not to watchdog timer.

We also need to select a prescalar of 256, for which the option bits PS2, PS1 and PS0 should be 111.

As the option register format is

Therefore its value to be set to 0 0 0 0 0 1 1 1 or 07 Hex

Thus the clock entering the 8-bit timer0 is 0.819MHz / 256 = 3199.22Hz. This corresponds to a time period of 1/3199.22 = 0.0003125 seconds.

As we need the interrupt to occur every 5ms, we need to (.005/.0003125) ticks of 3199.22Hz clock, that is 16 ticks.

Recall that timer 0 generates an interrupt when it overflows from max. count of 255 to 0, therefore we need to initialize it to a value of 256 - 16 = 240. This needs to be done every time it overflows. This will ensure that we get a continuous stream of interrupts every 5ms.

Hope this helps.

Add a comment
Know the answer?
Add Answer to:
The Timer 0 module of a 16F873A is to be used to generate a regular interrupt....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT