Homework 7 Solution

The laser is fired at a mirror placed on the moon and

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: ta bit of value 1 is 1. int sample; //used to store the timer count for each bit if(rise == 0) { sample1 = ICR1; //Set the timer to detect a rising edge. TCCR1B |= 0b01000000; rise = 1; } else { sample2 = ICR1; //Calculate the time duration of IR activity sample = sample2-sample1; //Based on the duration of IR activity, find out whether //the bit was a start bit, 1 bit or a 0 bit. if((sample>700) && (sample<800)) { bit =-1; } else if((sample>450) &&(sample<550)) { bit =1; } else if((sample>150) &&(sample<250)) { bit =0; } else{} //Set the timer to detect a falling edge. TCCR1B &= 0b10111111; rise =0; recv_ir_bit(bit); } } /* recv_ir_bit: receives a single bit from the above ISR */ void recv_ir_bit(char bit) { Name: Lab Section: // YOUR CODE //If start bit was received then clear recv_flag. if(bit== -1) { recv_ch = 0; recv_flag = 0; bit_count = 0; } else { //The LS bit is received first.We need to shift the bit to //the correct position. We do...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online