Access Official Technical PDF

Share Summary:LinkedInEmail

AVR digital signal processing can be a practical option for embedded applications that sample analog signals and process them in real time. The key design question is not simply how many instructions a microcontroller can execute, but whether its CPU can complete the required work before the next sample arrives. Three frequency-shift keying (FSK) demodulator implementations illustrate how sampling strategy and digital filtering affect processor utilization on an 8-bit AVR core.

The examples use an ADC to capture an incoming signal and C code to process samples, with assembly-language routines for 16-bit multiplication. Their results offer a useful way to assess processing budgets for similar embedded designs, while remaining specific to the implementations and clock rates described.

Why real-time processing depends on the sample interval

A sampled-signal application has a recurring deadline: each sample must be acquired and processed quickly enough to keep pace with the incoming data. The available CPU cycles per sample depend on the processor clock and the ADC sampling rate. At a 16 MHz clock, for example, a 6,250 Hz sample rate provides 2,560 CPU cycles between samples. Doubling the sampling rate halves that interval to 1,280 cycles.

Processor utilization expresses how much of this available time the application consumes. Lower utilization leaves more capacity for additional functionality or may allow a lower processor clock, subject to the application’s requirements. Higher sampling rates and added filtering increase the work, so engineers need to consider the complete signal-processing chain—not just the demodulation algorithm.

AFSK demodulation on an 8-bit AVR

The first implementation demodulates audio frequency shift keying (AFSK) signals used by the Specific Area Message Encoding protocol. Each bit lasts 1.92 milliseconds, corresponding to a bit rate of about 520.83 bits per second. A logic zero is represented by a 1,562.5 Hz tone, while a logic one uses a 2,083.3 Hz tone.

On an ATmega328P running at 16 MHz, the ADC samples at 6,250 Hz. The software stores the latest 12 samples in a circular buffer and applies two Goertzel bandpass filters, one for each tone. It compares the filters’ output magnitudes to decide which bit was received. Additional processing synchronizes to bit boundaries, and the resulting ASCII characters are sent through a USART.

The measured worst-case workload was 749 CPU cycles per ADC sample, or 29.3% utilization at 16 MHz. In this implementation, that leaves roughly 70% of the core available for other processing. The reported analysis also indicates that the clock could be reduced to 4.8 MHz without compromising this demodulator’s functionality, or that the signal and sampling parameters could be scaled by up to a factor of 3.4 if the clock remained at 16 MHz.

Using oversampling and FIR filtering to reduce aliasing

Sampling at 6,250 Hz puts the Nyquist frequency—the highest frequency that can be represented without aliasing—at 3,125 Hz. A higher-frequency interference tone can therefore fold into the frequency range of interest. For example, a 4,687.5 Hz tone sampled at 6,250 Hz appears at 1,562.5 Hz, the same frequency used to represent a logic zero. Such interference can disrupt demodulation.

One approach is to filter the analog signal before it reaches the ADC. The second implementation instead samples at 12,500 Hz, applies a 15-tap finite impulse response (FIR) filter, and then downsamples by two to return to 6,250 Hz. The filter is designed to attenuate frequencies above 3,125 Hz by more than 44 dB. This reduces the interfering signal before downsampling causes it to alias into the demodulation band.

The higher sample rate and FIR calculations raise processor utilization to 61.9% at 16 MHz, leaving about 38% available for other work. The implementation’s processing budget also supports reducing the clock to 10 MHz, or scaling the FSK bit rate, tone frequencies, and sampling rate by up to 1.6 at a 16 MHz clock.

Near-ultrasonic FSK with eightfold downsampling

A more demanding example processes near-ultrasonic tones of 16,666.7 Hz and 17,187.5 Hz, while retaining the same 1.92 millisecond bit duration. The ADC samples at 50 kHz. An interrupt service routine places incoming samples in a circular buffer for processing by the main loop.

A 9-tap FIR filter attenuates frequencies below 10 kHz by more than 40 dB, removing typical human voice frequencies from the signal. The filtered data is downsampled by eight to 6,250 Hz. At that rate, the two near-ultrasonic tones alias to 2,083.3 Hz and 1,562.5 Hz, allowing the original FSK demodulation stage to be reused.

At 16 MHz, measured utilization totals 66.6%: 20.3% for the sampling interrupt service routine, 18.3% for the FIR filter and associated overhead, and 28.0% for FSK demodulation and USART output. About one-third of the CPU remains available. The analysis also places the minimum clock for this implementation at 10.7 MHz, or allows signal parameters to scale by up to 1.5 at 16 MHz.

What the utilization results mean for design decisions

The three examples show the tradeoff between signal conditioning and available processing capacity:

  • AFSK at 6,250 Hz: 29.3% utilization at 16 MHz, with no FIR filter.
  • Filtered AFSK at 12,500 Hz: 61.9% utilization, using a 15-tap FIR filter and downsampling by two.
  • Near-ultrasonic FSK at 50 kHz: 66.6% utilization, using a 9-tap FIR filter and downsampling by eight.

At a 20 MHz clock, the reported utilization figures are 23.4%, 49.5%, and 53.3%, respectively. These percentages are tied to the stated code, device, clock, and processing tasks; they should not be treated as universal benchmarks for every AVR application.

Conclusion

For engineers evaluating embedded signal processing, the practical lesson is to budget cycles across the entire acquisition and processing path. ADC sampling, interrupt handling, digital filtering, demodulation, synchronization, and communications all contribute to CPU load. The examples demonstrate that an 8-bit AVR core can run these real-time FSK workloads while retaining some processing headroom, though the margin varies with sample rate and filtering requirements. Measuring utilization on the intended device and compiled application is essential when deciding whether the available capacity meets a project’s needs.

Access Official Technical PDF

About The Author