Homework 6 Solution

Previously the program used interrupts to update the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r the ADC conversion result to be ready. Write 1 to ADCS will start the ADC conversion. When it is done, the ADCS bit will return to 0. The program then may read the ADCW value. Question 6: ATmega128 ADC Programming (10 pts) Assume ATmega128 platform with the system clock configured to 4MHz (for improved power efficiency). Write two C statements to configure the ADC as follows: • Interrupt enabled • One- shot mode • ADC clock rate in the range of 50K- 200K Hz • Reference voltage is Vcc • No differential input Name: Lab Section: • • ADCW right adjusted The initial input channel is 7 Interrupt enabled ADIE = 1 One- shot mode ADFR = 0 ADC clock rate in the range of 50K- 200K Hz Make a table. The only good frequency is 125 KHz or 62.5KHz, for ADPS = 101 or 110 System clock rate is 4MHz ADPS 000 001 010 011 100 101 110 111 Div. Fac. 2 2 4 8 16 32 64 128 Freq. 2 MHz 2 MHz 1 MHz 500 KHz 250 Khz 125 KHz 62.5KHz 31.25KHz Reference voltage is Vcc REFS = 01 No differential input MUX4 and MUX3 are 0s ADCW right adjusted ADLAR = 0 The initial input channel is 7 MUX2, MUX1, MUX0 = 1,...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online