数字硬件测试题(英文版)
时间:2026-01-22
时间:2026-01-22
是大学三年级的数字硬件英文版本的题目
ECTE333: Digital Hardware 2
Spring Session 2008 ─ Class Test ─ Solution
Time: 60 minutes | Total marks: 20 | Worth: 5% of annual subject
1. Serial Port [5 marks]
a) Determine the value of relevant ATmega16 registers for serial transmission at a baud rate of
1200bps, eight data bits, one start bit, one stop bit, no parity bit, system clock 1MHz.
b) Explain the difference between the steps to send and receive a character through the serial port of
the ATmega16. a) There are four groups of relevant registers.
* UBRRH and UBRRL
UBRR = 1000000/(16 × 1200) ─ 1 = 51d = 0033H.
Therefore, UBRRH = 00H and UBRRL = 33H.
* UCSRA
0000000U2X = 0: normal speed mode
MPCM =0: disable multi-processor communication mode
* UCSRB
000
11RXEN = 1: enable receiver pin
TXEN = 1: enable transmitter pin
UCSZ2 = 0: together with UCSZ1:0 to select data size of 8 bits
UDRIE = 0: disable interrupt
*UCSRC
1000
0UCSZ1:UCSZ0 = 11: together with UCSZ2 to select data size of 8 bits
UPM1:UPM0 = 00: no parity
USBS = 0: 1 stop bit
UMSEL = 0: select asynchronous mode
URSEL = 1: to write to UCSRC register instead of UBRRH
是大学三年级的数字硬件英文版本的题目
b)
Sending
Check until UDRE flag is set to 1.
Write the character to register UDR for transmission.
void USART_send(unsigned char data){
// Wait until UDRE flag = 1
while ((UCSRA & (1<<UDRE)) == 0x00){;}
// Write char to UDR for transmission
UDR = data;
}
Receiving
Check until RXC flag is set to 1.
Read the received character from register UDR.
unsigned char USART_receive(void){
// wait until RXC flag = 1
while ((UCSRA & (1<<RXC)) == 0x00){;}
// Read the received char from UDR
return (UDR);
}
是大学三年级的数字硬件英文版本的题目
2. Timer 1 Input Capture Interrupt [5 marks] State the values of relevant registers, the required connections, and the key steps in the C interrupt-driven program.
Method
The period of a square wave is the time difference between two consecutive rising edges.
Connect the square wave to input capture pin of Timer 1 (ICP1/PD6).
Configure input capture module to trigger on a rising edge.
When input capture interrupt s triggered, read ICR1 register and reset Timer 1.
Required registers
Select timer operations: normal, no prescaler, internal clock 1MHz, noise canceller enabled,
input capture for rising edges.
TCCR1A = 0b00000000;
TCCR1B = 0b11000001;
Enable input capture interrupt:
TIMSK = 0b00100000;
Key steps in C interrupt-driven program: The shaded parts are key steps
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
int main(void) {
} return 0;
是大学三年级的数字硬件英文版本的题目
3. Pulse Width Modulator [5 marks]
A S3003 servo motor must be driven to an angular position using a PWM signal with a frequency of 50Hz and a duty cycle of 10%. Explain the steps and the relevant registers to produce the required
Period = 1/50Hz = 20000μs and high time = 20000μs £ 10% = 2000μs
Method
o Use Fast PWM mode WGM3:0 = 1110
o The TOP limit TOP is specified by register ICR1,
o Compare match is triggered by the value in register OCR1A.
o Set OC1A when compare match
o Clear OC1A when timer = 0.
Values of registers
1100Register TCCR1A
01Register TCCR1B
o ICR1 = 20000: eriod of output signal.
o OCR1A = 2000: pulse width of output signal.
o WGM3:0 = 1110: fast PWM mode where TOP = ICR1.
o CS12:0 = 001: internal clock, no prescaler.
o COM1A1:0 = 10: set OC1A when timer = 0, clear OC1A when compare match.
Therefore,
DDRD=0b00100000; // set port D for output (D.5 is OC1A)
TCCR1A = 0b10000010;
TCCR1B = 0b00011001;
ICR1 = 20000; // period of output signal
OCR1A = 2000; // pulse width of output signal
是大学三年级的数字硬件英文版本的题目
4. Analogue-to-Digital Converter [5 marks] Write a C program that uses the polling approach to perform analogue-to-digital conversion with the ATmega16.
The input signal is to be connected to pin ADC0.
The AVCC reference voltage and an ADC prescaler factor of 2 are used.
The digital result in two registers ADCH and ADCL is left aligned.
The top 8-bit of the digital result is to be displayed in PORTB.
State the values of relevant registers, and the main steps in your C program. : Step 1: Configure the ADC using registers ADMUX, ADCSRA, and SFIOR.
o What is the ADC source? [ADC0]
o What reference voltage to use? [AVCC]
o Align left or right the result in ADCH, ADCL? [left]
o Enable or disable ADC auto-trigger? [disable]
o Enable or disable ADC interrupt? [disable]
o What is the ADC prescaler? [2]
Step 2: Start ADC operation
o Write 1 to flag ADSC of register ADCCSRA
Step 3: Extract ADC result
o Wait until flag ADSC becomes 0.
o Read result from registers ADCL and then ADCH. 0 1 1 0 0 0 0 0
ADCMUX
ADCCSRA
#include<avr/io.h>
int main (void){
unsigned char result; DDRB = 0xFF; // set port B fo …… 此处隐藏:2998字,全部文档内容请下载后查看。喜欢就下载吧 ……