test3_sum08_sol - ECE 3724 Test #3 Summer 2008. You may use...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 ECE 3724 Test #3 – Summer 2008. You may use only the provided reference materials. Use functions DELAY_MS(), DELAY_US() as software delay functions. There are 7 pages, not including the figures page. You may skip ONE 6 pt problem (clearly cross it out ) for a total of 100 points. a. (15 pts) For the connection of Figure (a), write a function named uint8 testAND() that will test all four input combinations to the AND gate and return a ‘1’ if the AND Gate works as expected for all combinations, or a ‘0’ if it fails any combination. You can assume that the ports are pre-configured as inputs/outputs before entering the function, but make no assumption about the port’s initial states. Do a 1 μ s delay before reading the gate output after making a change on the gate’s input. You may not use macros for reading or writing the ports, you must use either _LATB x or _RB x names. uint8 testAND() { _LATB6 = 0; _LATB7 = 0; DELAY_US(1); if (_RB8 != 0) return 0; //failed _LATB6 = 1; _LATB7 = 0; DELAY_US(1); if (_RB8 != 0) return 0; //failed _LATB6 = 0; _LATB7 = 1; DELAY_US(1); if (_RB8 != 0) return 0; //failed _LATB6 =1; _LATB7 =1; DELAY_US(1); if (_RB8 != 1) return 0; //failed return 1; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 b. (15 pts) For the LED/SW I/O problem of Figure (b), implement the state chart in the Timer2 ISR (Timer2 has been configured for a periodic interrupt). You can assume the LED macro has been defined for LED output, and SW1_PRESSED( ) (true if pressed) and SW1_RELEASED() macros have been defined for the PIO. The state declarations and state variable are shown, feel free to add any additional global variables that you may need. 1. (10 pts) ISR code typedef enum { STATE_START =0 , STATE_BLINK; } STATE; volatile STATE e_mystate = STATE_START; ISRFAST _T2Interrupt() { _T2IF = 0; switch (e_mystate) { case STATE_START: LED = 1; if (SW_PRESSED) { do_blink = 1; e_mystate = STATE_BLINK; } break; case STATE_BLINK: if (SW_RELEASED) do_blink = 0; e_mystate = STATE_START; } break; }//end switch }//end ISR 2. (5 pts) main() code – just write the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 09/15/2009.

Page1 / 8

test3_sum08_sol - ECE 3724 Test #3 Summer 2008. You may use...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online