ECET20900 Test

ECET20900 Test - ECET20900 Test #2 Topics: Exam is...

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

View Full Document Right Arrow Icon
ECET20900 Test #2 Topics: Exam is 50minutes long and is closed book/notes Bring data sheets – without copious notes written on them – I will issue clean versions if necessary. One 8.5”x11” sheet of handwritten notes – you may use both sides. Hand it in with your solutions A mix of question types o short answer o some simple calculations o possibly multiple choice (very few) o questions that relate to an example program that is provided ALL class material covered so far could appear but I will focus on the following topics: Setting up PORTs and masking to isolate bit for input and output intmain (void) { unsigned char i; /* statement declaring a temporary (local to main) variable */ DDRA = 0x00; /* set PORT A pins to all inputs */ PORTA = 0xFF;/* enableall PORT A pull up resistors */ DDRC = 0xFF;/* set PORT C pins to all outputs */ PORTC = 0xFF;/* set all LEDs to off */ while(1) { i= PINA;// read the state of toggle switches
Background image of page 1

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

View Full DocumentRight Arrow Icon
PORTC = i; // output state of toggles to LEDs } // end of while(1) loop return0 ; } // end of main() // End of program Notes: C statements:DDRA = 0x00 ; // end with a semi-colon C blocks: consist of a group of c statements enclosed in braces { }. Usually C blocks are run based on some logical condition(s) while(1) { i= PINA; PORTC = i; } Summary on I/O PORT set-up: • Unused pins on a PORT should be set to INPUTS with pull-up resistors turned ON or external pull-up resistors connected. • DDRx register bit settings: logical 0 = INPUT, logical 1 = OUTPUT. e.g. DDRA = 0xCA; (0b11001010) port pins A.7, A.6, A.3 and A.1 are O/Ps the rest are I/Ps • PORTx register: To turn ON the pull-up resistor for any port pin that is set as an input, set that bit in the PORTx register to 1 i.e. logical 1 = pull-up ON for a port pin set as an input. If any port pin is set as an OUTPUT or the corresponding PORTx bit is set to logic 0 then the internal pull-up resistor is disconnected. e.g. Assuming PORTA configured as above (DDRA = 0xCA) then the instruction: PORTA = 0x34; (0b00110100) means PORTA pins A.5, A.4 and A.2 have pull-up
Background image of page 2
resistors ON and input A.0 has the internal pull-up resistor OFF. All four output pins (A.7, A.6, A.3 and A.1) also have their internal pull-up resistors disabled . • PORTx register: is also used to set the state of any OUTPUT pins on PORTx.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

ECET20900 Test - ECET20900 Test #2 Topics: Exam is...

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

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