
ADC and SPI
Learn about Analog-to-Digital Converter (ADC) basics, usage on AVR boards, and Serial Peripheral Interface (SPI) fundamentals for efficient programming. Explore tasks involving ADC drivers, SPI communication, and OLED display interaction to enhance your AVR skills.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Analog-to-digital converter (ADC) Converts an analog, continuous, signal into discrete representation. Both continuous time and voltage are converted into discrete values in a conversion. Resolution measured in bits (eq. 10 bits) Sampling rate (or sampling frequency) determines the rate at which values are converted. Nyquist theorem states that the sample frequency has to be twice that of the highest frequency in the sampled signal (Fs >= 2* Fsig)
ADC usage on the AVR Initializing an ADC on the AVR can be accomplished like this: Set the bit resolution (we use 8 bit in this task) Select the reference voltage Set the ADC clock prescaler so the speed is between 50kHz and 2MHz Enable the ADC Getting a sample from the ADC: Choose which ADC input channel to use Clear the ADC conversion done interrupt flag. Start a new conversion. Wait for the conversion to complete by monitoring the interrupt flag. Read out the value from the result register.
SPI (Serial Peripheral Bus) Used to communicate between two or more devices. Serial communication (in contrast to parallel) Data is usually sent 8 bits at a time Full duplex Master-Slave 4-wire serial bus
SPI Typical Bus Daisy-chained Bus
SPI usage on the AVR Initializing Configure SS pin as output. Enable SPI and set clock divisor (in this task dividing by 4 is fine). Transmit: Set the SS low on the correct slave. Fill the data register with the 8 bits (one char) you want to send. Make a while loop to wait for data transmition to complete. Set the SS high again.
Todays tasks Make an ADC driver to read the pot-meter value. Send the pot-meter values to your terminal with the UART. Make a SPI driver. Use the spi driver to talk with the OLED using the handed out OLED driver. Have some fun with the OLED. Make a simple game!