CE351 lec43 Final exam overview
Overview
Yiyan Li reviews CE351 final-exam topics covering ADC timing and register setup, timer CTC configuration, sampled-signal analysis, threshold-triggered acquisition, and SD-card buffering. Key calculations include a maximum usable ADC prescaler of 32, a 799 timer compare value for a 50-microsecond period at 16 MHz, and 25.6 milliseconds to fill a 512-byte buffer at one byte per 50-microsecond sample.
Key takeaways
- A 13-cycle ADC conversion at a 16 MHz clock must use a prescaler no greater than about 61.5 to meet a 50-microsecond sampling deadline, making 32 the largest supported choice below the limit.
- ADC prescaler 32 produces a 26-microsecond conversion and 24 microseconds of timing slack per 50-microsecond sample period.
- For a 16 MHz timer in CTC mode with no prescaler, a 50-microsecond period requires OCR1A = 799 because the counter starts at zero.
- In the threshold-triggered acquisition state machine, the first out-of-range reading changes the state but is not stored; later readings are stored even if they fall back inside the thresholds of 116 and 140.
- A 512-byte buffer filled with one-byte samples at 50-microsecond intervals takes 25.6 milliseconds to fill, so alternating buffers lets SD-card transfer proceed while the other buffer collects data.
- The SD interface must account for 3.3-volt card signaling against 5-volt microcontroller logic, and the reviewed hardware uses a level shifter.
Chapters
- An ADC conversion requires 13 ADC clock cycles and must finish within the 50-microsecond sample period.
- At a 16 MHz system clock, the timing bound is 16 MHz × 50 microseconds ÷ 13, or about 61.5 for the prescaler.
- Because 64 exceeds the bound, the largest available usable ADC prescaler is 32.
- Configure ADMUX for the AVCC reference with REFS0 and left-adjusted output with ADLAR; channel A0 remains at its default zero selection.
- Set ADEN and ADIE in ADCSRA to enable the ADC and its interrupt, and set ADPS2 plus ADPS0 for prescaler 32.
- At 16 MHz divided by 32, each ADC clock takes 2 microseconds, so a 13-cycle conversion takes 26 microseconds and leaves 24 microseconds of a 50-microsecond period.
- In CTC mode, the timer counts from zero to the OCR compare value, so calculate the count and subtract one.
- With a 16 MHz clock, no prescaler, and a 50-microsecond period, OCR1A is 799; an 8 kHz rate uses the same period-to-count method.
- CTC is timer mode 4, binary 0100; WGM12 is the asserted mode bit in TCCR1B, while the lower WGM bits are in TCCR1A.
- Count upward crossings to identify periods, then average the intervals between sample indices 12, 52, 91, 131, and 171.
- Each index step represents 25 microseconds; multiply the average interval by 25 microseconds to estimate the signal period, then take its reciprocal for frequency.
- The acquisition thresholds are 116 and 140, set as 128 ± 12; readings such as 115 or 150 trigger a transition into acquisition.
- The triggering sample changes the state but is not stored; subsequent readings are stored in the acquisition state even when they return within the threshold range.
- Two memory regions alternate roles: one collects incoming samples while the other holds a full block for transfer to the SD card.
- A full buffer is marked unavailable for sampling until its data has been written and it is marked empty again.
- Double buffering is presented as a technique for fast audio or RF acquisition, where limited on-chip memory and slow storage transfers can otherwise cause lost samples.
- At one byte per sample and one sample every 50 microseconds, a 512-byte block fills in 25.6 milliseconds.
- The review distinguishes block-by-block SD access from a FAT-based file library, which can incur roughly 50 milliseconds per operation.
- The acquisition code uses alternating buffers and block-level transfers to manage SD-card writes while sampling continues.
- An SD-card level shifter bridges the card's 3.3-volt signaling and the microcontroller's 5-volt logic.
- The closing PWM review identifies timer mode 14 and notes that its equations are provided for the exam.
- The transcript ends as Yiyan Li begins comparing equation-based PWM calculations with the method used in class.
Transcript excerpt
0:10 Yeah, because the thing is um when you divide by four you are you are extracting this this these two digits. Right? So you're considering that these two digits are decimal numbers or the fraction numbers are the fractional part of it. Yeah, think about this a little bit. That's what we think we'll revisit we'll come back. Let's go through everything first. I hope we'll revisit if we still have time, okay? Um so what is the largest ADC prescaler you can use so a certain cycle conversion finishes within one sample period. Does still remember how this is
0:58 done? Remember we have a well two two ISRs. Okay, so the so the conversion ISR is 25 microseconds for each each time and then it starts the conversion. When the conversion is done it starts reading it. So um when when when so the conversion takes certain cycles and certain cycles means 13 clock rising edges, okay? That's needed for the ADC. So there's a prescaler for the ADC is being set up by the by the register. Eventually um you have to know that frequency first so
1:46 you know how long this takes. So originally you have a 60 megahertz. So what is the largest ADC prescaler you can use so certain cycle conversion within one sample period. So we assume that this is one sample period just finishes within 50 microseconds. Right? So when you do 16 megahertz divided by the prescaler times 13. So 60 megahertz is the fastest signal you have from the chip and divided by the prescaler give you the the frequency used for the for cycling for for for sampling, right? Not for sampling, for the conversion.
2:35 And it takes 13 cycles. So you divide by 13 again, so eventually you are getting
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Yiyan Li.