This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ECE 3724/CS 3124 Test #3 – Summer 2005- Reese. You may use only the provided reference materials. All figures are on the last pages. Part I: (72 pts) a. (5 pts) Write C code that configures PORTB for the IO shown in the figure for problem (a) on the Figure sheet. The internal weak pullup must be enabled. Do not assume any default bit values. b. (15 pts) Assuming the IO configuration of the previous problem, write a while(1){} loop that implements the LED/Switch IO state machine shown for problem (b) in the figures. Either use a switch() statement approach or a if-then-else approach. Assume you have available the DelayMs() function for blinking the LED; you do NOT have to include debounce delays for the switch input.c. ( 20 pts) For the LED/Switch configuration shown in Figure (a), implement the flowchart of figure (c) in an interrupt driven manner. Divide your solution into two code segments -- an ISR, and main() code that includes the declarations of any variables used by the ISR and main(), initialization code for the interrupt system, and initializes the LED to OFF. You do not have debounce the input switch. You cannot have any delay code in the ISR to that waits for input. Your infinite loop in main() has to be an infinite loop that is an EMPTY infinite loop while(1){}; your ISR has to do all of the work. 1. (13 pts) ISR code (do not worry about debouncing the switch inputs). 2. (7 pts) main() code, your while(1){} has to be empty; the ISR must do all of the work.d. (7 pts) Assume an asynchronous serial channel with a data format of 1 start bit, 8 data bits, and 1 stop bit between characters. If I wanted to guarantee that eight characters would be transmitted in 3 ms, what is the MINIMUM baud rate I could use from the standard baud rates of 4800, 9600, 19200, 38400, 57600, 76800 or 115200? You must show your WORK in order to get any credit for this problem. Assume the receiver accepts data as fast as I transmit it. e. (7 pts) Write C code that implements the void putch(char c) function (transmits one character to the serial port). No interrupts are enabled. f. (9 pts) Write a C code function that waits for availability of data in a circular buffer, then reads data out the circular buffer and returns it. Assume the variables declared below; the head pointer is used to place data into the buffer, the tail pointer is used to take data out of the buffer. #define BUFSIZE 16 char head, tail; char buf[BUFSIZE] // implements storage for circular bufferg. (9 pts) Given the code below and Figure (g), answer the questions: g.1 This produces a periodic waveform; draw it starting at time 0 and continue for a couple of cycles. g.2 What determines the HIGH PULSE WIDTH time? g.3 What determines the LOW PULSE WIDTH time? interrupt my_isr() { if (INT1IF) { INT1IF = 0; RB5 = 1; } }//end my_isr() main() { TRISB5 =0; TRISB1 = 1; RB5 = 1; INTEDG1 =0; IPEN = 0; INT1IF =0; INT1IE = 1; GIE = 1; while (1) { RB5 = 0; } // end while() } //end main()Part II: (28 pts) Answer 7 out of the next 9 questions. Cross out the 2 questions that you do not want graded. Each question is worth 4 pts. 1. Given a voltage of 3 V, a clock freq of 10 MHz, and a current consumption of 5 mA, what is the new current consumption predicted by theory if the voltage is increased to 4 V V and the clock frequency to 20 MHz? 2. Draw a picture that shows how an open-drain output differs from a normal CMOS output. 3. In the code below, a student is trying to detect a power-on-reset, but a mistake has been made. Correct the code. main() { serial_init(95,1); // 19200 in HSPLL mode, crystal = 7.3728 MHz if(!POR) { printf(“Power-on-reset detected!”);pcrlf(); } //rest of code4. What is the SPBRG value for a baud rate of 38400 assuming an FOSC of 15 MHz and high speed mode? 5. In the code below, what will happen assuming the standard PIC18 setup that you have been using in lab? main() { serial_init(95,1); // 19200 in HSPLL mode, crystal = 7.3728 MHz printf(“Daylight Savings Time is Evil!”);pcrlf(); SWDTEN = 1; while (1) { // do nothing }//end while() } //end main() 6. Can I hook the PIC TX and RX pins directly to pins 2, 3 of the DB9 to implement my serial port connection to the PC? If NO, why not? What is needed?7. Draw a diagram that shows how to measure the TOTAL current flowing into your PIC18F242 breadboard setup, including the current used by the voltage regulator. 8. For the 7-bit value 0x4E, what is the value of the parity bit if EVEN parity is used. What types of errors is a parity bit guaranteed to detect? A change in one bit value? A change in two bit values? A change in more than two bits? 9. The PIC18 automatically saves the registers BSR, W, and STATUS into the shadow registers when an interrupt occurs for either a low or high priority interrupts. Assume that you had a system with both low and high priority interrupts. What is the first thing that your low priority interrupt service routine should do with the values saved in the BSR, W, STATUS shadow registers? Explain why. Is this also necessary for the high priority ISR? Why or Why


View Full Document

MSU ECE 3724 - TEST 3 SUMMER

Documents in this Course
Timers

Timers

38 pages

TEST 4

TEST 4

9 pages

Flags

Flags

6 pages

Timers

Timers

6 pages

Timers

Timers

54 pages

TEST2

TEST2

8 pages

Load more
Download TEST 3 SUMMER
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view TEST 3 SUMMER and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view TEST 3 SUMMER 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?