首页 > > 详细

辅导 EEC 7 Introduction to Microcontrollers辅导 留学生R语言

EEC 7

Introduction to Microcontrollers

TI BOOSTXL-EDUMKII BoosterPack

Lab4_Part1 Project Initialization

• Use the provided “EEC7_Lab4_P1_Project.zip”as the default starting point, find this archive in Canvas →Files →Micro-controller Labs.

a. From the Project Explorer, select Project > Import CCS Projects > Select archive file. Click the Browse button and navigate to the downloaded EEC7_Lab4_P1_Project.zip file.

b. Click Finish to import the project.

c. Rename the project and write your code in “main.c”.

• When starting a new lab, remember to fill in the information on top of “main.c”. You will see a few #include statements that we have prepared for you. Do not remove any of them, they are just there for Laboratory 4 , but you can add additional #include if you want.

• You should give the new project a new name, such as Lab4_part1 or bouncing_ball.

Lab 4, Part 1 Overview – Bouncing Ball

Objective: To develop a program that simulates a ball bouncing from the edges of the Booster Pack LCD screen.

• A ball is defined by the (x,y) coordinate of its center and radius.

• The ball moves after each SysTick interrupt* using the expression:

➢x = x + vx

➢y = y + vy

assuming vx, vy can be positive or negative.

• When the ball reaches an edge of the LCD, it should reflect off the wall such that the angle of incidence equals the angle of reflection.

Origin located at upper-left corner!

Coordinates indicated as pixel #

*What regulates the rate for the ISR?Reload Value

Reminder: SysTick Timer will service ISR

Program Specifications

• The circle should be redrawn in time-steps of about 50 – 100 ms. Therefore, a SysTick interrupt should be generated at a rate of 1/0.1 = 10 to 1/0.05 = 20 Hz.

• Do not draw, or erase, circles from within the SysTick ISR. Instead, set a flag in the SysTick ISR to signal the main function to erase the old ball and draw the new ball.

• The recommended radius for the circle is 3 to 4 pixels.

• The program should initiate with a circle close to the center of the screen. Recall that upper left corner is coordinate (0,0).

• The circle should start with a small initial velocity, for example:

▪ vx = 1 pixel / time-step

▪ vy = -1 pixel / time-step

Program Specifications-cont.

• Adding the x-velocity to the current x-coordinate will push the circle radius to the screen’s left or right boundaries, then the x-velocity should be inverted (how can we do this?).

• Similarly, if adding the y-velocity to the current y-coordinate will push the circle radius to the screen’s upper or lower boundaries, then the y-velocity should be inverted.

• To make the program more interesting, when the ball bounces off the wall at x = 0 or x = 127, increase the magnitude of the x-velocity by one up to a maximum of about 15. The microcontroller will not be able to update the ball for larger velocities.

• Similarly, when the ball bounces off the wall at y = 0 or y = 127, increase the magnitude of the y-velocity by one up to a maximum of 15.

Flowchart


❑ Your program will have 3 parts:

• Initialization code including:

➢ Watchdog Timer

➢ LCD

➢ SysTick Timer

• Main loop i.e. while (1)

• SysTick ISR

❑ A timer flag variable will be set in the SysTick ISR and polled in main. It must be cleared in main. (Why?)

❑ How should timer flag be defined?




联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!