$4
In this lab you will perform tasks designed to acquaint you with the Nuvoton Nu-LB-NUC140, a prototype/development board. You will also become familiar with using the Keil μVision Integrated Development Environment (IDE) to create your C programs.
The board is programmed and controlled by Keil μVision which is installed on the lab’s PCs. A version of Keil μVision is also available as a free download for your personal computer, see the tutorial. Keil MDK ( μVision), the BSP provided by Nuvoton, and the NUC140 make it possible to quickly develop and verify the design of micro-controller applications. Figure 1 shows the programming setup we will use for the board. This lab has two parts – Lab1a and Lab1b.
Figure 1: Programming Setup (picture courtesy of Nuvoton)
CAUTION! Even this seemingly simple, introductory lab is time-consuming if working with Keil and the NUC140 for the first time.
Pre-lab Assignments:
Familiarize yourself with the Technical Reference Manual, the Driver Reference Guide, and the User Manual for the Nu-LB-NUC140 V2 board. Available on Canvas.
Read the tutorial, available on Canvas.
Complete the Pre-lab Questions for both parts – Lab1a and Lab1b.
Note: Each student must conduct the labs by themselves. You are not allowed to copy codes/content or to pair-up with other students to complete the labs. Each student must demonstrate individual tasks (after completion) to the professor and teaching assistant to get the full marks for the demo.
In-lab Tasks:
In-Lab Tasks are a suggestion for the minimum amount of work to complete in the lab. You must maintain lab safety, such as unplugging the Nu-LB-NUC140 board when appropriate. However, feel free to do more and varied tasks than what are detailed. Document and report in your lab write-up all your lab efforts. For each of the following subprograms, create a new project, or at a minimum a new Main program. Program listings are required for each task, which includes all the code in the Main program, not just the snippet that executes a specific task. It is equally important to have the initialization code to indicate the board setup.
Part 1 – Lab 1a:
The goals of Lab1a are to familiarize yourself with setting up a new project in Keil, writing code that accesses the 4 red LEDs, the RGB LED, the timer/interrupt, and LCD screen as well as the drivers available to you. The peripherals you will be using in this lab are shown in Figure 2.
Follow all the steps necessary to complete Tutorial 1.
Repeat these steps on your own to make a different pattern on the LEDs, both red and RGB LEDs.
At this point you have used the Delay option to set the frequency of the blinking lights. Now use a timer/interrupt to control the frequency. Use a frequency that blinks the LEDs every half second. This may (or may not) require a different clock initialization.
Initialize the LCD screen and write “Hello World” to the screen.
Demonstrate each of the above to your professor and teaching assistant.
Figure 2: Peripherals for Lab 1a
Part 2 – Lab 1b:
The Lab1b will focus on other on-board peripherals, specifically the 7-segment display, the keyboard, the buzzer and the dedicated interrupt button. The goals of Lab1b are to familiarize yourself with setting up a new project in Keil, writing code for a heartbeat signal, the 7-segment display, the buzzer and the interrupt button. Figure 3 shows the location of the different peripherals for this lab.
Create a heartbeat signal using an interrupt routine and one of the RGB LEDs.
Display 2018 on the 7-segment display.
Use the interrupt button to sound the buzzer.
Using the Keypad as numbers 1-9, display the corresponding number for each button push.
Using the keypad and other buttons, display 0-9 on the 7-segment display.
Using the keypad and other buttons, also display 0-9 on the LCD screen.
Demonstrate each of the above to your professor and teaching assistant.
Figure 3: Peripherals for Lab 1b
Parts List:
The items on this list will NOT be repeated in the lab write-up but they are necessary for all labs.
PC
Nuvoton Nu-LB-NUC140 V2.0 board
USB to microUSB cable
Cables (2-wire and 1-wire)
4. Deliverables:
Lab Write-up. This is a technical document. Use complete sentences and logical paragraphs. Document any changes you made to the programs in both the report and on the program listings. Feel free to make changes and “do your own thing”, just so long as your efforts are greater than what is requested by the assigned tasks. For this first lab a one or two page write-up is sufficient. Later labs will require more effort. Follow the Lab Report Format as well as the Rubric for Lab1. The report should include:
Introduction including a summary of the lab tasks for Lab 1a and Lab 1b
In-Lab tasks for both Lab1a and Lab1b, problems encountered, your solutions, including hardware and software.
In lab tasks, problems encountered, your solutions, including hardware and software.
Discussion and conclusion
All the lab reports should be typed and turned in as a hard copy on time (check the syllabus for due date), and a soft copy should be forwarded to the Teaching Assistant: Srikanth Ramadurgam on the due date and time.
Program listings. Print a hardcopy of the c code you wrote for each task for inclusion in your lab report. Include listings for all programs for Lab1a (4 programs – a,b,c below) and Lab1b (d and e below). Note: you could organize your Lab1b code into 2 programs as in d and e below.
The two versions of blinking LEDs with delay function
LEDs with timer/interrupt function (heartbeat)
Part 1 – Lab 1a:
2 points each, 10 points total. Be sure to include units, as appropriate, with your answers.
(2 pts) The Nu-LB-NUC140 development board has 5 clock options; provide the name, frequency, and whether they are internal or external.
(2 pts) How many independent sets of timers are supported? List and describe the Timer operation modes (4) available on the Nu-LB-NUC140 development board.
(2 pts) Which timer option/mode would work best for a periodic interrupt of ½ second?
Periodic Mode
(2 pts) How do you calculate a ½ second “time out period” for the flashing LED?
(2 pts) What drivers from the BSP are needed to support your code in #4
Full Name:
Part 2 – Lab 1b:
10 points total. Be sure to include units, as appropriate, with your answers.
(3 pts) Using the schematic or the TRM identify the pins associated with each peripheral and whether the peripherals/pins are inputs or outputs.
7-Segment displays (there are 4 displays)
Keypad
Interrupt button
Buzzer
LEDs RGB
LEDs red (there are 4 red LEDS)
(3 pts) What prevents you from displaying 2 different numbers on 2 of the 7 segment displays at the exact same time?
Explain
Using pseudo code, describe how you might make it look as if the numbers are displayed at the same time. Think raster scan or frame rate. (pseudo code or actual code is fine)
(3 pts) Compare the 7-segment display and the keypad
What is the similarity between the 7-segment display and the keypad? (look at the GPIO pins)
What is the difference
How would you make the keypad work? Pseudo code is fine.
(1 pt) In what folder (CMSIS, Library, or Source) would you put the drivers for the LCD display and the 7 Segment display?