Homework 7 Solution

Int sample used to store the timer count for each bit

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: lt;<CS10); //0b10000011=0x83 TIMSK = (1<< TICIE1) ;//0x00100000=0x20 sei(); } c. [15] Complete the following program that accepts characters through IR. It has two functions (ISR (TIMER1_CAPT_vect)and recv_ir_bit()). The ISR recognizes a single bit, which can be a start bit, a data bit of value 0 and a data bit of value 1. It then calls recv_ir_bit() with this bit as the parameter. The start bit is passed as - 1. The recv_ir_bit() function works as follows: If it sees a start bit, then it resets recv_flag and clears recv_ch. If it sees a data bit, then it shifts the bit into recv_ch. If all seven bits are received, then it also sets the recv_flag. // global variables exchange IR data between interrupt // functions and the foreground program execution // YOU MAY ADD MORE GLOBAL VARIABLES TO THIS SECTION Name: Lab Section: volatile char recv_ch; volatile char recv_flag; // receive character // receive flag // recognize a single bit ISR (TIMER1_CAPT_vect) { char bit; // The bit values: start is -1, // data bit of value 0 is 0, // da...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online