Exam 3 Topics

Errata

If you find errors in the past exams or in this review guide, please email me at prl83@msstate.edu. It will be worth a small bonus to your lab grade.

Exam 3

The following table examines the last fifteen Exam 3s, dating back to Summer 2018: 

Notes

If we remove the unlikely topics, our table now looks like this:

UART

Identify the bit

Since there are 13-14 parts to this subquestion, each worth a point, it is worth the bulk of the points in the UART section, and is the reason why UART is the highest-weighted topic on Exam 3:

Every question since Spring 19 has been either A) 8 data bits, no parity, 1 stop bit (like above), or B) 7 data bits, 1 parity bit, 1 stop bit. (The 2018 questions were "7 data bits, odd parity, 1 stop bit", which for the sake of these questions is the same as the 7-1-1 ones.) Both versions of the question are easy, so it really doesn't matter which one you get, but here is a table showing Spring and Fall exams only:

Disclaimer: Past performance does not guarantee future results.

Additionally, a lot of the same waveforms are recycled; however, it's not worth the time to try to memorize or predict them. Instead, here are the simple rules that you need to solve these questions. Put them in your cheatsheet:

Here is an illustration of that for the above question from Spring 24:

Here's one of the 7-1-1 types from Fall 23:

*Joke - Q: How do you top a car? A: Tep on the brake, tupid!)

Hex value

In the waveform above, what is the hex value of the data transmitted? This question, or a variant of it, is asked almost every time.

Parity

Odd parity means that the total number of 1s in the data and parity bit combined has to be odd. Even parity means that the total number of 1s in the data and parity bit combined has to be even.

Using this, we can work backwards and determine whether the parity is odd or even.  In the above data there are four 1s. Four is an even number. The parity bit is high, for a total of five 1s, Five is an odd number, so that means the parity is odd. If the question were phrased differently, and told you that the parity was supposed to be even, then asked if the data was transmitted correctly, the answer would be no.

Baud rate

Spring 24: What is the minimum possible time required to send 20 bytes over a UART operating at 115,200 baud using 8 data bits, 1 parity bit, and 1 stop bit? Give your answer in ms, accurate to at least 3 significant digits.


8 data + 1 parity + 1 stop + 1 start bit they didn't mention = 11 bits per byte

20 bytes * 11 bits/byte = 220 bits we need to send.

We can send 115,200 bits/second, so 220/115,200 = 0.001909722222... seconds. 

We have to give the answer in ms, so bump the decimal point over 3 notches: 1.9097222 ms

It wants at least 3 significant digits, so 1.91 (1.910, 1.9097, and 1.90972 are also acceptable)*


* As is 1.90972 followed by holding down the '2' key indefinitely. So is 1.9149999999999999, though 1.91499999999999999 is not. The lowest acceptable answer seems to be 1.90499999999999992. Now go back to studying.

Digital inputs and outputs

Put this table in your cheatsheet:

Whatever the table says, if the button is pressed, it grounds the pins, making the voltage 0 !

Summer 18

Although it's been a long time since the Digital I/O questions took this form, nevertheless I would be on the safe side and copy the correct code snippet and the following factoids onto your cheatsheet:

// configure an LED on pin RA2

#define CONFIG_LED1() (CONFIG_RA2_AS_DIG_OUTPUT())

// configure a pushbutton on pin RA2

void config_pb1(void) {

    CONFIG_RA2_AS_DIG_INPUT();

    ENABLE_RA2_PULLUP();

    DELAY_MS(1);

}

Watchdog timer

This type of question appears on almost every Exam 3. You're given the following instructions: 

A PIC33 (or PIC24) programmed with the following code is powered on at 0 seconds. What is printed on the screen, and at what times? Assume the watchdog timer is programmed to expire in ___ seconds. See Fig. 1 for information on the WDTO bit. When power is first applied, assume _SWDTEN = 0.

(Fig. 1 is a link that just jumps you to the Power-on reset diagram, but it is unnecessary to solve these questions.) Then there's a C program, which for your reference while clicking back to study old exams:

These questions are quite hard for several reasons:

We've got you covered here for #1 and #2, but for #3, you're on your own. Besides plenty of practice, I would recommend making a tidy list on scrap paper to keep track of when everything happens, and then going back and doing this question from scratch a second time after you've finished the rest of the exam. As for #1 and #2, the good news is the list of rules that you need to learn put in your cheatsheet is actually fairly short:


[1]  Errata

* It is very unlikely that this would happen in an early interval, so if you find yourself writing "X" in the last six blanks, you've probably done something wrong.

Interrupts

These are also hard questions. Again, there are only a handful of rules to remember/write down and they're better documented in the lecture notes and ebook, but you have to keep track of all them at once, along with the table of pushbutton presses and releases. One lapse in concentration and goodbye points.

A PIC24 interrupt occurs when all of following conditions are satisfied simultaneously:

Two other important things to remember for these questions:

Timers

Timer Configuration

The first parts of these questions are all the same - and very easy. You look at this part of the datasheet: 

Then you type 0b in the answer box (it doesn't matter what the question asks for - always answer in binary so you don't mistakes) and fill it out based on the specifications in the question. For example, from Spring 24:

What value for T2CON configures timer 2 to run, continue operation in idle mode, disable gated time accumulation, use a 1:8 prescale, operate as a 16-bit timer, and use the internal clock as its clock source? All undefined or unspecified bits must be chosen as 0.


TON  -   TSIDL  -  -  -  -  -  -  TGATE  TCKPS[1:0]  T32  -  TCS  -

 1   0     0    0  0  0  0  0  0    0       01        0   0   0   0


So 0b1000000000010000 

Just remember;

Timer Period

The second part of these questions is almost as easy. You probably already have this formula in your cheatsheet from the lecture notes:

This is for Timer2. For Timer3, we use PR3, but the formulas are otherwise the same.

All but two of the exams use the bottom version of the formula and ask you to solve for PR2, but since you're given frequency instead of clock period, and timeout period is referred to as "interrupts every _____", a more useful version is:

PR2 = (interrupts_every x freq / prescaler) - 1

The Fall 19 exam asks for "the period of interrupts" aka timeout period, so on that question you would use the top version and do:

period_of_interrupts = prescaler x (PR2 + 1) / freq 

Spring 22 asks:

Assuming a 1:256 prescale for timer 2 running on the internal clock of Fcy = 40 MHz, how much time is 200 timer ticks? Give your answer is ms.

For this question, use the formula:

timer tick = (1 / freq) x prescaler

So we get:

timer tick = (1 / 40M) x 256

timer tick= 0.0000064 s

200 timer ticks = 0.00128 s = 1.28 ms

For all these questions, remember:

Power-on reset

These questions are similar to the Watchdog timer and Interrupts ones in that you have to answer with what is printed in various time periods, and need to be careful not to make a foolish mistake. However, despite not being covered in the lecture notes or ebook, they are easier because they tend to be very similar from semester to semester, and you're given a datasheet with virtually all the information you need. Here's a more useful version of that datasheet with the rows that have actually been applicable to past exam questions:

*A brownout reset has never occurred in any past exam.

**You could set all these flags in the code, for example _POR=1. However this has never been done on any past exam.

The only thing you have to know:

This should be intuitive, but it doesn't specifically say it in the datasheet, so there it is.

Waveout interrupts

These questions have only appeared twice, on Summer 20 and Spring 21. At first glance, they appear cruel hard, combining Interrupts and Timers; but they eschew the trickery of the former and are just straightforward calculations of the timeout period.

Use this version of the formula:

timeout = prescaler * (PR2 + 1) / freq

All the calculations conveniently come out to whole milliseconds, and there's no button pushing or PIC resetting to throw you off. Give them a try if you're done with your other studying. The only real way to screw them up is to forget, as the question says, that "All times are measured from when the program began running, not from the last toggle."


Good Luck and God Bless!