Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need some help with these microcontroller questions ELEN 216 MICROCONTROLLER T

ID: 2266162 • Letter: I

Question

I need some help with these microcontroller questions

ELEN 216 MICROCONTROLLER TECHNOLOGY Electronic Engincering Technology Fall 2017 01. 112 Marks I. What is the last instruction of most intcrrupt service routines in assembly? What does this instruction do? 121 2. A PICI 8F452 is running with a l 6MHz crystal osillator. Determine the value to be written into the PR2 register to generate periodic interrupts every 8ms. Assume that both the prescalar and postscalar values are set to 16. [21 3. Figure QI. Shows Timer 0 block diagram in 16 bit-mode. Briefly explain the 16-bit read and write operations. 12] Data TOOK Figure Q1.

Explanation / Answer

1- return is the last instruction.

There are two return instructions- 'ret' and 'reti'.

The only difference between the two is 'reti' also sets the global interrupt bit I in SREG.

The ISR() macro (from interrupt.h) will give the interrupt function the attribute of 'signal', which means in addition to other details, the compiler will put a 'reti' at the end of the interrupt function.

If you put a return anywhere in you code (C code), it will end up being a 'ret', with the I bit left unchanged. So if you call a function from within an ISR, the called function will not re-enable interrupts when it returns (because it will use 'ret