Revision Lecture Flashcards

1
Q

How do you create binary numbers?

A

0b
0B
B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create Hexadecimal numbers?

A

0x
0X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

For the DDRx, what is an input and what is an output?

A

0 = Input
1 = Output

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can I make all pins on port A into input pins?

A

DDRA = 0b00000000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can I make the 4 lower bits of port B an output and the 4 higher bits into inputs?

A

DDRB = 0b00001111

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
DDRA = 0x00; //Set port A as input
x = PINA;

What does the second line do?

A
//Read contents of port A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What can PORTx - Port x Data Register do?

A
  • Output data
  • Activate / Deactive Pull Up Resistors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can I output 0xFF on Port B?

A
DDRB = 0b11111111; //Set all pins of port B as outputs
PORTB = 0xFF; //Write data on port
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can I output data in variable x on port A?

A
DDRA = 0xFF; //Make port A an output
PORTA = x; //Output variable on port
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Aliasing?

A

Two or more signals have the same sampled representation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the ADC resolution of an analog signal with a maximum value of 3.3V with a 10-bit ADC?

A

2^10 = 1024
3.3/1024 = 3.22mV

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the ADC frequency formula?

A

Frequency of CPU / Prescaler value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the available ADC Prescaler Values?

A

2, 4, 8, 16, 32, 64, 128

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

If I have a CPU frequency of 16MHz and use a prescaler of 64, what is the effective frequency?

A

16MHz / 64 = 250kHz

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the global interrupt bit?

A

sei()
cli()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an ISR?

A

Interrupt Service Routine

17
Q

How do you write code for an ISR?

A
ISR(INT_vect)
{
}
18
Q

What are the rules for writing an Interrupt Service Routine?

A
  • Keep it short
  • Don’t use delay(), serial prints
  • No input variables or returned variables
  • All changes have to be made on global variables
  • Shared variables should be declared volatile
19
Q

How do the ATmega2560 External Interrupts work?

A

INT7:0
Reset Pin = Pin30
PCINT23:0: Pin Change Interrupt

20
Q

How many steps are in an 8 bit timer?

A

256 steps
0 to 255

21
Q

What are the prescaler values available for a clock?

A

8, 64, 256, 1024

22
Q

How many timers are in the Atmega2560 and how many bits do they have?

A

Timer/Counter 0, 2: 8 bit
Timer/Counter 1, 3, 4, 5: 16 bit

23
Q
ISR(TIMER0_OVF_vect) //TIMER0 overflow interrupt service routine.
//This ISR is called automatically whenever TCNT0 overflows
{tot_overflow++; //Count the number of...
}
int main(void)
{ DDRL |= (1 << PL0); //connect LED to PL0
timer0_init(); //initialise Timer0
while (1)
{ if (tot_overflow >= 12) // Check if...
{ if (TCNT0 >= 53) // Check if...
{ PORTL ^= (1 << PL0); // toggles the led
TCNT0 = 0; // Reset the...
tot_overflow = 0; // Reset the...
}
}
}
}

Finish the comments

A
ISR(TIMER0_OVF_vect) //TIMER0 overflow interrupt service routine.
//This ISR is called automatically whenever TCNT0 overflows
{tot_overflow++; // count the number of overflows
}
int main(void)
{ DDRL |= (1 << PL0); //connect LED to PL0
timer0_init(); //initialise Timer0
while (1)
{ if (tot_overflow >= 12) // check if no. of overflows = 12
{ if (TCNT0 >= 53) // check if the timer count reaches 53
{ PORTL ^= (1 << PL0); // toggles the led
TCNT0 = 0; // reset the counter
tot_overflow = 0; // reset the overflow counter
}
}
}
}
24
Q
A