Professional Documents
Culture Documents
GJ201909011057 Assegment
GJ201909011057 Assegment
GJ201909011057 Assegment
1.What are the components of the bus and what are their functions?
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
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.
(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