CH4 Review Questions Flashcards
There are a total of _____ ports in the ATmega32.
4
True or False.
All of the ATmega32 ports have 8 pins.
True
True or False.
Upon power-up, the I/O pins are configured as output ports.
False
Code a simple program to send 0x99 to Port B and Port C.
LDI R16, 0xFF
OUT DDRB, R16
OUT DDRC, R16
LDI R16, 0x99
OUT PORTB, R16
OUT PORTC, R16
To make Port B an output port, we must place ______ in register ______.
$FF, DDRB
To make Port B an input port, we must place _____ in register ______.
$00, DDRB
True or False.
We use a PORTx register to send data out to AVR pins.
True
True or False.
We use PINx to bring data into the CPU from AVR pins.
True
True or False.
The instruction “SBI PORTB, 1” makes pin PB1 HIGH while leaving other pins of PORTB unchanged, if bit 1 of the DDR bits is configured for output.
True.
Show one way to toggle the pin PB7 continuously using AVR instructions.
CBI DDRB, 7
H1: SBI PORTB, 7
CBI PORTB, 7
RJMP H1
Write instructions to get the status of PB2 and put it on PB0.
CBI DDRB, 2
SBI DDRB, 0
AGAIN: SBIS PINB, 2
RJMP OVER
SBI PORTB, 0
RJMP AGAIN
OVER: CBI PORTB, 0
RJMP AGAIN
Write instructions to toggle both bits of PD7 and PD0 continuously.
SBI DDRD, 0
SBI DDRD, 7
H2: SBI PORTD, 0
SBI PORTD, 7
CBI PORTD, 0
CBI PORTD, 7
RJMP H2