GJ201909011057 Assegment

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Name: HASAN MEHEDI

Student ID: GJ201909011057


Class: 2019 F

I、 Choice questions. (3 points for each)


1.The word length of the microcomputer is ()
A. Binary bits that the computer can directly process at a time
1-A
2-C
3-D
4-C
5-D

II、Short answer question

1.What are the components of the bus and what are their functions?

A: The data bus is a two-way pathway carrying the actual data (information) to and


from the main memory.
The control bus holds the control and timing signals needed to coordinate all of the
computer’s activities.

2- What is the role of interface technology?

An interface is essentially a border point where two or more components of a


computing system meet and interact by shariis a two-way pathway carryin1-
The data bus is a two-way pathway carrying the actual data (information) to and from
the main memory.
The control bus holds the control and timing signals needed to coordinate all of the
computer’s activities. interface is essentially a border point where two or more
components of a computing system meet and interact by sharing data and others.
3.What are the methods for exchanging data between the device interface and
the CPU?
Programmed i/O, Interrupt-initiated I/O, and Direct Memory Access (DMA)

An interface is essentially a border point where two or more components of a


computing system meet and interact by sharing data and others.

4.What is the difference between serial communication and parallel communication?


-In the case of serial transmission of data, the data gets transferred bit by bit. On the
other hand, in parallel transmission, only a character or a single byte (or 8 bits) is
transmitted at any given time. We use both of these to connect with the peripheral
devices and also communicate with them.

III、Programming question
1.According to the program code, write the program that meet the requirements.
(1) Press the WKUP_PRES to control the light-off of LED0.
(2) Press KEY0_PRES to control the light-off of LED1.
(3) Press KEY1_PRES to control the enable of the buzzer.

while(1)
{
key=KEY_Scan(0); // get the key value
if(key)
{
switch(key)
{
case WKUP_PRES: //Control LED0
LED0 = !LED0;
break;
case KEY0_PRES: //Control LED1
LED1 = !LED1;
break;
case KEY1_PRES: //Control the buzzer
BEEP = !BEEP;
//BEEP=1;
//delay_ms(1000);
//BEEP=0;
break;
}
}else delay_ms(10);
}

2. According to the following program code, the interrupt frequency of Timer 3 needs
to be changed to 1Mhz. Please write the modified program. (15 points)

int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//Set system interrupt
priority group 2
delay_init(168); //Initialize the delay function
LED_Init(); //Initialize the LED port

TIM3_Int_Init(5000 - 1, 84 - 1); //The timer clock is 84M, and the


frequency division factor is 84, so the counting frequency of 84M/84=1Mhz,
counting 5000 times is 500ms
while (1)
{
LED0 = !LED0;//DS0 Rollover
delay_ms(200);//Delay 200ms
};
}

3.Write the corresponding subroutine according to the functions provided below. (Just
write the function name, for example LCD_DrawPoint (40,50);) (15 points)

(1) Draw a circle with coordinates x = 30, y = 60 as the center and a radius of 30.

//Draw a circle of the specified size at the specified position


//(x,y): center point
//r : radius
void LCD_Draw_Circle(u30 x0,u60 y0,u30 r){
int a,b;
int di;
a=0;b=r;
di=3-(r<<1); //Judge the sign of the next point position
while(a<=b)
{
LCD_DrawPoint(x0+a,y0-b); //5
LCD_DrawPoint(x0+b,y0-a); //0
LCD_DrawPoint(x0+b,y0+a); //4
LCD_DrawPoint(x0+a,y0+b); //6
LCD_DrawPoint(x0-a,y0+b); //1
LCD_DrawPoint(x0-b,y0+a);
LCD_DrawPoint(x0-a,y0-b); //2
LCD_DrawPoint(x0-b,y0-a); //7
a++;
//Use the Bresenham algorithm to draw a circle
if(di<0)di +=4*a+6;
else
{
di+=10+4*(a-b);
b--;
}
}
}

(2) Draw a rectangle with starting coordinates x = 50, y = 160, and ending coordinates
x = 150, y = 260.

// draw rectangle
//(x1,y1),(x2,y2): diagonal coordinates of the rectangle
void LCD_DrawRectangle(u50 x1, u160 y1, u150 x2, u260 y2)
{
LCD_DrawLine(x1,y1,x2,y1);
LCD_DrawLine(x1,y1,x1,y2);
LCD_DrawLine(x1,y2,x2,y2);
LCD_DrawLine(x2,y1,x2,y2);
}

(3) With starting coordinates x = 50, y = 400, text box height 24, width 100, font size
24, display the string "Interface Technology 2022".

//display string
//x,y: starting point coordinates
//width, height: area size
//size: font size
//*p: string starting address
void LCD_ShowString(u50 x,u400 y,u100 width,u24 height,u24 size,u32 *p)
{
p = “Interface Technology 2022”
u32 x0=x;
width+=x;
height+=y;
while((*p<='~')&&(*p>=' '))//Judge if it is an illegal character!
{
if(x>=width){x=x0;y+=size;}
if(y>=height)break;///quit
LCD_ShowChar(x,y,*p,size,0);
x+=size/2;
p++;
}
}

Thank You

You might also like