' ' '
,di G,,' 0.,, ~ ,q ~
"!!'el ... '.i'~~'\..ln ri n'l~1 ... L~~'Vl'\.J-:l~'el'!J ... ..
SI ,ct ~
'II el 11'0 lJ fl UH ill fl tl Ti t1 fl'lfl YI 1/2560 .,
.. .
.,..
ct ..,
til'll 'rl'IHi.ftl'U
Tl-!YI 25 tlln.JlU\.! Vi.fl. 2560
~
.
1'1fl CPE363 Embedded Systems Design
n,n
09:00 -12.00 'I-!.tfl't111J\!tlfffllf11t11fn'i1Jflt)1Jrf119161il!il~ 3-4
tlltl-.1
'i ,,
0 .,i O , , , , lit,,4. 0'4t1Jl~ inn lfl'iO-.tflll!1W 1'\111-rn-:iirnu ii>'l
i ,,, .,.,. ... ,,,,
lJJ"5. V'4t1Jl~ 1-ru1 'Hl!-:iao rnnan 'H'iO 1u1111'\lrnv-:iirou 1,1 6. tt lll'Wl,i'e:iirouoon'il1ntt0-:iffou
D
' ' '
-=I c v v ~ -=:ilcv
°ll'el ... rn~unl"lm::r1 ... b~"ll'Vl'W~~'tlu ... ..
I. Fill the relation of questions with the answer a toe. (20 points)
Size of SBlW's Result _ _ Size of Stack pointers (SP)
Size of GPR32 _ _ Size of X register _ _ Size of Status Register _ _ Size of Program Counter (PC)
a.
b.
C.
d.
e.
Size of Data bus
Size of EEPROM Data Size ofGPR0
Size of Nibble
4-bit 8-bit 16-bit 32-bit Don't know
2
' ' '
~ .... v ~ .:::ilv
'll?l ... rn'i'lt.lnr1m:t1 ... L~"llYl'iJ,,:J'i'l?JU ... .
2. Explain this program does. (20 points)
.INCLUDE "M32DEF.lNC"
LOI Rl6,0x00 OUT DDRC,Rl6 LOI R 16,0xFF OUT DDRB,Rl6 L2: IN Rl6,PINC
LDl Rl7,5 XOR Rl6,Rl7 OUT PORTB,Rl6 RJMP L2
I. What is DDRC? - - - -
2. What is DDRB? - - - -
3. How long does program run?
4. What is the PORTB output? _ _ _ _ _ _ _ _
' ' '
.di - CV' -:! ~ -
"ll'tl ...
rn~t.mrJm:n. ...
l'Wll'Vl'W-:t~'tltJ ... .3. Write small assembly program to receive key presses form low 4-bit PORTS and drive high 4-bit PORTS LED. (20 points)
4
' ' '
di Q."V":3 ~ I V
'll'fl ... r~~unrim~1 ... b~"llYlU~~'flu ... .
4. Assume XT AL
=
8MHz, Find the serial configuration by debug the following program.(20 points)
a. What is data size?
b. What is Baud Rate?
c. What is Parity Bit?
d. How many Stop bit?
e. What is the data sent?
.INCLUDE "M32DEF.INC"
LDI Rl6, (l<<TXEN) OUT UCSRB, R16
LDI R16, (l«UCSZl) I (l<<UCSZ0) I (l<<URSEL) OU1' UCSRC, Rl 6
LDI Rl6, 0x33 OUT UBRRL, R16 AGAIN:
SBIS UCSRA, UDRE RJMP AGAIN LDI
OUT RJMP
Rl6, 'G' UDR,Rl6 AGAIN
' '
.=,I.,
.:ii CV CV ~
'l!'tl ...
rvi~un~n~1 ..
... b'i'l6JIV1'1..\'1~'t!U ... .U1
PB01CLK1/XTAL 1/PCINTB PAO/AOCO/AREFIPCINTO ~;
P81/XTAL2/PCINT9 PA 1/A.DC1/AINOIPCINT1 i - - = - - - '
PB2/CKOUTIOCOMNTO/PCINT10 PA2JAOC2/AIN11PCINT2 1--1 1.,..1
0- - - ' PB3/0WJRESET/PCINT 11 PA3/AOC3/TOIPCINT3 I - - " " ' - - - '
ATTINY84
PA4/ADC4/USCK/SCUT1/PCINT 4 1--'9
<---'
PA5IADC5/00/MISO/OC1BIPCINT5 - ~ - - - - PA6/AOC6JMOSI/SDNOC1AIPCINT6 ~ - - - _ .
PA7/ADC7/0C0811CPIPCINT7
1---'
6
'
' ' '
d:il c v c v ~ .c:ilcv
"l!'el ... :r'Vl~'Wnl"ln'r!'1 ... b'i'l"ll'Vl'W..:J~'el'LI ... ..
1 1
2
3
4
#define
#define
#define
#define
#define
#define
#define
2 3 4 5 6 7
LCD_PRT PORTA LCD_DDDR DORA LCD_DPIN PlNA LCD_CPRT PORTB LCD_CDDR DDRB LCD_CPIN PINB LCD_RS 2
#define LCD_RW 1
#define LCD_EN 0 unsigned char spc[8]
{0,10,10,10,0,17,14,0}; ;
void lcdCommand(unsigned char cmnd) { {
}
LCD_DPRT = cmnd;
LCD_CPRT &= -(l<<LCD_RS);
_delay_us(l);
LCD_CPRT I= (l<<LCD_EN);
_delay_us(l);
LCD_CPRT &= - (l<<LCD_EN);
_delay_us(20);
void lcdData(unsigned chard) { {
}
LCD_DPRT = d;
LCD_CPRf I= (l<<LCD_RS);
_delay_us(l);
LCD __ CPRT I= (l«LCD_EN);
_delay_us(l);
LCD_CPRT &= -(l«LCD_EN);
_delay_us(20);
8
void lcd_build(unsigned char location, unsigned char *ptr)
{ {
unsigned char i;
9
10 11
12 13 14 15 16void lcd_print(unsigned char *str) { {
unsigned char i =0;
while(str[i]!=0) { {
lcdData(str[i]);
i++;
} }
void lcd_init_my() { {
}
LCD_DDDR = 0xFF;
LCD CDDR = 0xFF;
LCD __ CPRT &=-(l«LCD __ EN);
LCD_CPRT &=-(l«LCD_RW);
_delay_us(2000);
lcdCommand(0x38);
_delay_us(100);
lcdCommand(0x0e);
_delay_us(100);
lcdCommand(0x01);
_delay_us(2000);
lcdCommand(0x06);
_delay_us(100);
void main() { {
}
lcd_init_my();
lcd_build(0,spc);
lcdData(0xC0);
lcdData(0x00);
lcd_print("CPE_363");
DAAW CG il\M