Assume that 0x6000 TMR0 counts is equal to 0.1 seconds. The programmer of the following program expects it to remain in the while loop for 0.1 seconds. Explain what you probably will observe and why.

TMR0 = 0x0000;

while(1) {

if (TMR0 == 0x6000) break;

OTHER_STUFF();

}

Timer 0 is running in 16-bit mode with: 1:2 prescalarFosc = 64MHzTMR0 initial value is 0

How long until TMR0 rolls over?

What initial value and prescalar of an 8-bit counter will generate a 300uS delay with Fosc = 12MHz?

You have an application which required you to measure a time interval. You have the choice of three prescalars, 1:16, 1:32, and 1:64. Which one do you use. Justify your answer with a numerical example (or three).

Generate a 15mS delay on a 10MHz PIC with TMR0 running in 16-bit mode. Determine the (best) prescalar and initial TMR count value. Show your work.

Timer 0 is running in 8-bit mode:Fosc = 16MHz64 entry LUTTMR0 initial value is 0

What is the frequency resolution of the DDS waveform?

You need to program your PIC to compute the square root of a 12-bit number with a fair degree of accuracy. Suggest a fixed-point format for the result in the form “x.y” where x is the number whole number bits and y is the number of fractional bits.

Briefly describe in three steps (no more, no less) how to determine which button was pressed in the following circuit.

You are writing an ISR to debounce a button. The button is aliased to the variable BUT_IN, and the cleaned button is output to a global variable CLEAN_BUT. Complete the program below, don’t worry about clearing the timer interrupt flag or setting the timer in the ISR.

//------

// TMR0_ISR

// Clean up the BUT_IN

//------

void TMR0_ISR() {

static int8 state = 0;

state = (state < 1) | ______

if (state == ______) CLEAN_BUT = 1;

if (state == ______) CLEAN_BUT = 0;

} // end TMR0_ISR

The quickest a person can press and release a button is 0.18 seconds. What is the slowest rate that the above ISR should be called while insuring that all button press events can be detected?

You are to build a subroutine to determine the SQUARE of a fixed point input. The input to the SQUARE function is an 8-bit fixed point number where the decimal point is between the upper and lower nibble. The output of your function is the square of the input. The output of the SQUARE function should be a 16-bit fixed point number where the decimal point is between the upper and lower byte. The square function should be based on a 5-entry LUT and utilize linear interpolation. Complete the function using the variables given and the comments associate with each.

unsigned int16 SQR(unsigned int8 x) {

int16 square[5] = {0x0000, 0x1000, 0x4000, 0x9000, 0xFFFF};

int16 base, difference, result;

int32 fraction;

int8 index;

/* The index into the square array. */

index = ______;

/* The base value of the linear interpolation. */

base = ______;

/* The difference btw the base "square" value and next value.*/

difference = ______;

/* How much of the difference should be added to the base.*/

/* The product of two 16-bit numbers produces a 32-bit result.*/

fraction = difference * ______;

/* align the decimal point of the 32-bit fraction with the base.*/

result = base + (fraction >______);

return(result);

} // end SQR

Convert 14.36 into a 4.4 fixed point value. Show your result in hex.

Write a C-code snippet to clear every bit, but bit 2, of an 8-bit variable X.

Write a C-code snippet to set every bit, but bit 2, of an 8-bit variable X.

Write a C-code snippet to add 1 to a variable x modulo 64.

You are approximating the function y=x3 with a LUT. Where will the LUT encounter the most error? Use calculus concepts to justify your solution.