Homework 7 Solution

# Draw the digital circuit to allow the edge detector

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: an analog input into the ATMega128 has a positive edge. (5 pts) Specifications: 1) The analog input (A_in) is attached to channel 3 of the ADC 2) The ADC must be configured for Single- Shot mode 3) The reference voltage for the ADC will be the same as in Lab: 2.56V 4) A high (i.e. logic 1) is defined as A_in > 2V, A low (i.e. logic 0) is defined as A_in < .5V. int main(void) { unsigned int rising_edge_time; // Used to determine the logic 0 and logic 1 threshold int VOLTAGE_0_5V = 200; // Digital ADC value for .5V // ADC = Vin/.0025 =.5/.0025 = 200 int VOLTAGE_2_0V = 800; // Digital ADC value for 2.0V // ADC = Vin/.0025 = 2/.0025 = 800 //Configure the ADC // Bits 7-6 // Bits 5 // Bits 4-0 : REFS1 REFS0 = 11 (set to internal 2.56 V_REF) : ADLAR = 0 (set ADCW to be right justified) : MUX4 MUX3 MUX2 MUX1 MUX0 = 00011 (set to channel 3) ADCMUX = 0b11000011; // // // // // Bits Bits Bits Bits Bits 7 6 5...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online